% jecon.bst: 経済学用 BibTeX style file.
%
% First-written:       <2002/11/03>
% Time-stamp:	       <2008-12-22 18:22:05 Shiro Takeda>
% Version 2.6
%
% $Id: jecon.bst,v 1.9 2008/12/22 09:26:40 st Exp $
%
% これは,飯田修さんによって作成された jpolisci.bst を経済学用に
% 武田史郎が改変したものです.
% 改変には
%
% aer.bst, jfm.bst, jplain.bst
% 萩平哲さんによる <http://www.med.osaka-u.ac.jp/pub/anes/www/latex/bibtex.html>
% 樋口耕一さんによる nissya.bst <http://hey.to/KO-ichi>
%
% 等を参考にさせていただきました。これらの有益なプログラム、ページを作成し
% てくださった方々に感謝します。
%
% 元の jpolisci.bst の著作権は飯田さんにあります.
% わたしが改変した部分の著作権はどうでもいいです.好きなように扱ってください.
%
% オリジナルの jpolisci.bst は,
% <http://www.bol.ucla.edu/~oiida/jpolisci/> で入手することができます.
% (注:2006年現在ではもうこのページは存在しないようです.どこで入手できるかは
% わかりません).
%
% コメント,要望は武田史郎まで.
%
% 変更履歴 (Changelog) は CHANGES.txt ファイルを見てください.

% version 指定
FUNCTION {jecon.version} { "2.6" }

% Debug mode.0 以外を指定すると様々な情報を表示させることが可能.
FUNCTION {jecon.debug}
{ #0 }    % Debug mode off.
% { #1 }    % Debug mode on.


% 以下は元の jpolisci.bst のヘッダー部分です.
%
%%%%%% ここから Original header.
%
% JPOLISCI: a bibliography style for papers in political sicence
%           and other fields that cite Japanese literature.
%           Vertical writing (tate-gaki) compatible.

	% Version 20000910 for JBibTeX versions 0.30 or later,
        % and pLaTeX2e or later.
	% Copyright (C) 2000, all rights reserved.
	%
	% This file was derived from jbtxbst.doc.
	%
	% Copying of this file is authorized only if either
	% (1) you make absolutely no changes to your copy, including name, or
	% (2) if you do make changes, you name it something other than
	% jbtxbst.doc, jplain.bst, junsrt.bst, jalpha.bst, jabbrv.bst,
	% tipsj.bst, jipsj.bst, tieice.bst, jname.bst, jorsj.bst, jglsj.bst,
        % seg.bst, jpolisci.bst.
	%
	% This restriction helps ensure that all standard styles are identical.
	% The file jbtxbst.doc has the documentation for this style.
	%

        % Author:
        %
        % 飯田修 Osamu Iida
        % email: oiida@newmail.net
        % URL  : http://www.bol.ucla.edu/~oiida/jpolisci/ (in Japanese)
        %
        % Bug reports, technical suggestions and any other comments
        % will be appreciated.
        % 

        % Acknowledgement:
        %
        % The following files were referred to while creating this file:
        %
        %   jglsj.bst  (by 千葉智章 Tomoaki Chiba)
        %     Function "format.lab.name" in jpolisci.bst derived from
        %     it with small modifications only. The author appreciates it.
        %
        %   seg.bst (by Martin Karrenbach)
        %     A method for making two sorts of labels is based on this
        %     file's feats.
        %
        %   jalpha.bst (by 松井正一 Shoichi Matsui)
        %     jpolisci.bst principally owes its functionality to it.
        %
        %   藤田眞作『続 LaTeX2e 階梯・縦組編』(アジソン・ウェスレイ、1998 年)。
        %
        % Friends in BBSes at IR-web <http://pws.prserv.net/oi/ -- now
        % obsolete> and KH's Web Site <http://home.att.ne.jp/wind/polisci/>
        % gave me titles of Japanese political science journals which are
        % included in MACROs.

        % This file is distributed with absolutely no warranty.
        % The author doesn't assume any kind of responsibility for
        % any inconvenience caused by using this file.

        % Last modified: 2000/12/05

%%%%%% Original header ここまで。
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%	用語

%% 「エントリー」:一つの文献のこと.エントリーのタイプとは article,book 等の
%% 文献の種類のこと.

%% 「フィールド」:エントリー内で指定されている title, author, year 等のこと.

%% 「キーワード」:\cite命令の引数となる各エントリーに指定されている文字列のこ
%% と.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%	カスタマイズのための関数
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% \bysame を使うか否か。使わないなら 0、使うなら 0 以外を指定 (bst ファイ
% ルでは整数を表すとき数字に # を付ける)。
% \bysame とは、参考文献部分同じ著者名が連続するときに --- で省略するもの。
%
FUNCTION {bst.use.bysame}
{ #1 }     % #0 以外 -> Use \bysame
% { #0 }    % Not use \bysame

% \bysame の定義。\bysame を使ったときの横棒の形式を変えるには以下の定義を修正
% する。
%
FUNCTION {bst.bysame.definition}
{ "\hskip.3em \leavevmode\rule[.5ex]{3em}{.3pt}\hskip0.5em" } 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Economics の reference では, first author 名は「姓, 名」の順番で表記し、
% second author 以下は「名 姓」とするという場合が多いが、これを変更するための関数。
% Editor にも適用。日本語文献は関係なし。#0 か #1 か #2 を選択可。
%
FUNCTION {bst.author.name}
{ #0 }    % (default)
% { #1 }
% { #2 }

% [#0 のケース] これ普通の経済学風。
% Fujita, Masahisa, Paul R. Krugman, and Anthony J. Venables. 

% [#1 のケース] 全員「姓, 名」のケース。
% Fujita, Masahisa, Krugman, Paul R., and Venables, Anthony J.

% [#2 のケース] 全員「名 姓」のケース。
% Masahisa Fujita, Paul R. Krugman, and Anthony J. Venables.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Author (editor) 名の first name を頭文字だけに略す。
%
FUNCTION {bst.first.name.initial}
{ #0 }    % #0 -> 略さない。 (default)
% { #1 }    % #0 以外 -> first name を頭文字に略す。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Title の先頭文字以外を小文字に変換する (book の tile は除く。元々小文
% 字ならなにも変わらない)。
%
FUNCTION {bst.title.lower.case}
{ #0 }    % #0 なら小文字に変換しない (そのまま)  (default)
% { #1 }    % #0 以外なら、小文字に変換する。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 同じ年に同じ著者の英語、日本語文献の両方があり、かつ日本語文献の yomi
% に英語文献の著者と同じものが指定してあるときに、両者を混ぜて表示するた
% めのオプション。
% yomiを日本語で書いているなら関係なし.
FUNCTION {bst.mixed.order}
{ #0 }    % #0 -> 混ぜない.普通はこちら. (default)
% { #1 }    % #0 以外 -> 混ぜる。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% month を表示するか否か。隠す(表示しない)なら 0 以外、隠さない(表示する)なら 
% 0 を指定。隠す場合でも month フィールドの値は並べ替えのキーとしては利用され
% る。これも普通は変更しない.
FUNCTION {bst.hide.month}
{ #0 }    % #0 -> 表示する.普通はこちら. (default)
% { #1 }    % #0 以外 -> 隠す (表示しない)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% number filed を表示するか否か。隠す(表示しない)なら 0 以外、隠さない(表示す
% る)なら 0 を指定。これも普通は変更しない.
FUNCTION {bst.hide.number}
{ #0 }    % #0 -> 表示する.普通はこちら. (default)
% { #1 }    % #0 以外 -> 隠す (表示しない)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% これの値に 0 以外を指定すると、reference 部分で plain.bst のように文献
% の前に number index ([1]のようなもの)を付けることができる (引用部分は
% author-yearで変わらない)。
%
FUNCTION {bst.use.number.index}
{ #0 }    % Not use number index  (default)
% { #1 }    % #0 以外 -> Use number index

% number index の前に付ける文字列 (bst.use.number.indexに0以外を指定していると
% きのみ有効).
%
FUNCTION {bst.number.index.pre}
{ "[" }    % (default) 

% number index の後に付ける文字列。 \hskip1.0em は空白の大きさ。空白の長さは自
% 分で調整したほうがよい。 (bst.use.number.indexに0以外を指定しているときのみ
% 有効).
FUNCTION {bst.number.index.post}
{ "]\hskip1.0em " }    % (default)

% number index の最大の桁数 (文献が100個以上なら3、100個より少ないなら2、10個よ
% り少なければ1を指定)。とりあえず 3 を指定しておけば問題ないが、3 だとインデン
% トが大き目になる。値は 1, 2, 3 のどれかを指定.
%
FUNCTION {bst.number.index.digit}
{ "3" }    % (default)

% 以下は、number index を表示するときに見た目を調整するための関数。computer
% modern 以外のフォントを使用するようなときは要調整。
%
% Reference 部分の文献の2行目以降のインデント幅の値を指定.
%
% bst.number.index.digit の値によってインデント幅は変わるので,それぞれのケース
% について指定する.
%
% bst.number.index.digit = 1 のときの設定
FUNCTION {bst.number.index.bibhang.one}
{ "2.05em" }    % (default)
% bst.number.index.digit = 2 のときの設定
FUNCTION {bst.number.index.bibhang.ten}
{ "2.55em" }    % (default)
% bst.number.index.digit = 3 のときの設定
FUNCTION {bst.number.index.bibhang.hund}
{ "3.05em" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% year の表示位置を変更。
%
% 0 なら author のすぐ後に year を表示。0 以外なら year は後ろにもってくる。後
% ろとは note フィールドがなければ一番最後,note フィールドがあれば note フィー
% ルドを表示する前.
FUNCTION {bst.year.backward}
{ #0 }    % (default)
% { #1 }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 日本語文献の数字を漢数字にする.
%
% 縦書き用です.
%
% 0 以外なら漢数字に変換。
FUNCTION {bst.kansuji.jp}
{ #0 }    % 変換しない。(default)
% { #1 }    % 漢数字に変換する。

% bst.kansuji.jp が非ゼロのときに,pages でのページ数とページ数を結ぶ線の定義
% を指定する.pages = 100-200 と指定しているときに,"-" に置き換わる線の定義.
%
% 縦書きの表示を指定しているときでも - は横棒のまま表示されます.これを縦棒に
% 表示するための指定です.
% 
FUNCTION {bst.tatebo.definition}
{ "\hskip.1em \leavevmode\rule[0ex]{1em}{.3pt}\hskip0.1em" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 0 以外を指定すると新しい年の文献を前にもってくる。
%
% 0 なら普通の並び順。通常は 0 のままでいいでしょう.
%
FUNCTION {bst.reverse.year}
{ #0 }    % 普通の並び順 (古い文献ほど上) (default)
% { #1 }    % 普通とは逆 (新しい文献ほど上)

% 0 以外なら year を優先的なキーとしてソート(並べ替え)をする。
% 
% 普通では古い文献ほど上に並べられるが、bst.reverse.year が非ゼロなら新しい文
% 献ほど上となる。
%
FUNCTION {bst.sort.year}
{ #0 }    % この場合、year は author に次ぐソートのキー (普通のケース) (default)
% { #1 }    % この場合、year は最優先されるソートのキー

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 引用順で参考文献を並べる設定.
%
% 0 以外を指定すると引用をしたそのままの順で reference に文献を並べる.\bysame 
% と一緒に利用すると表示がおかしくなるケースあり.
%
FUNCTION {bst.no.sort}
{ #0 }    % 文献の順番を普通にソートする.(default)
% { #1 }    % 引用順に並べる.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 文献の並べ替えのとき文献エントリーのタイプ別 (article, book, incollection 等)
% にまとめるための設定.
%
FUNCTION {bst.sort.entry.type}
{ #0 }    % #0 -> タイプ別にまとめない.(default)
% { #1 }    % まとめる.
%
% この設定は absorder よりも優先します.どういう順番で並べるか (article, book,
% incollection 等をどう並べるか) は bst.sort.entry.type.order という関数の設定
% で決まります.デフォールトでは alphabet 順にしてあります (article, book,
% booklet, comment,..., unpublished 順).詳しくは jecon-sample.pdf を参照。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 文献の並べ替えのとき absorder filed の値を利用するか否か。利用するなら
% 0、利用しないなら 0 以外を指定。
%
FUNCTION {bst.notuse.absorder.field}
{ #0 }    % #0 -> 利用する。(default)
% { #1 }    % #0 以外 -> 利用しない。
%
% Reference での文献並べ替えの優先順序については 
% 
% absorder -> author (or yomi) -> year -> order -> month -> title
%
% としてある。詳しくは jecon-sample.pdf を参照。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 文献の並べ替えのとき order filed の値を利用するか否か。利用するなら
% 0、利用しないなら 0 以外を指定。
FUNCTION {bst.notuse.order.field}
{ #0 }    % #0 -> 利用する。(default)
% { #1 }    % #0 以外 -> 利用しない。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%	and

%%% 二人の authors, editors の間の文字列
%
% "Mr.A _ Mr.B " の "_" の部分に入る文字列
%
FUNCTION {bst.and}
{ " and " }    % (default)

%%% 三人以上の authors, editors の間の文字列
%
% "Mr.A, Mr.B _ Mr.C" の "_" の部分に入る文字列
%
FUNCTION {bst.ands}
{ ", and " }    % (default)

% 複数の authors, editors の間の文字列 (日本語文献用)
%
% "A氏 _ B氏 _ C氏" の "_" の部分に入る文字列
%
FUNCTION {bst.and.jp}
{ "・" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%	「引用部分」での author 名の間に入る文字列

%%% 二人の authors, editors の間の文字列
%
% 引用部分の "Mr.A _ Mr.B " の "_" の部分に入る文字列
%
FUNCTION {bst.cite.and}
{ " and " }    % (default)

%%% 三人以上の authors, editors の間の文字列
%
% 引用部分の "Mr.A, Mr.B _ Mr.C" の "_" の部分に入る文字列
%
FUNCTION {bst.cite.ands}
{ " and " }    % (default)

% 複数の authors, editors の間の文字列 (日本語文献用)
%
% 引用部分の "A氏 _ B氏 _ C氏" の "_" の部分に入る文字列
%
FUNCTION {bst.cite.and.jp}
{ "・" }    % (default)


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% 何人以上の著者がいるときに引用部分で et al.で省略するか。3人以上のとき
% に略すときは #3 を指定。
FUNCTION {bst.and.others.num}
{ #3 }    % 3人以上なら省略する。(default)
% { #4 }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%	author 名を略す際の文字列

%%% 英語用
%
FUNCTION {bst.and.others}
{ " et~al." }    % (default)

%%% 日本語用
%
FUNCTION {bst.and.others.jp}
{ "他" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	author 

% author の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.author.pre}
{ "" }    % (default)

% author の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.author.post}
{ "" }    % (default)

% author の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.author.pre.jp}
{ "" }    % (default)

% author の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.author.post.jp}
{ "" }    % (default)

%%% 日本語文献の author, editor の姓・名の間に入れる文字列 
% (姓名のどちらか一方が一文字のケース)
%
FUNCTION {bst.sei.mei.one.jp}
{ "" }    % (default)
% { " " }

%%% 日本語文献の author, editor の姓・名の間に入れる文字列 
% (姓・名とも二文字以上のケース)
%
FUNCTION {bst.sei.mei.two.jp}
{ "" }    % (default)
% { " " }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	year

% year の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.year.pre}
{ " (" }    % (default)

% year の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.year.post}
{ ") " }    % (default)

% year の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.year.pre.jp}
{ " (" }    % (default)

% year の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.year.post.jp}
{ ") " }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	title (book 以外)

% title の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.title.pre}
{ "``" }    % (default)

% title の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.title.post}
{ ",''" }    % (default)

% title の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.title.pre.jp}
{ "「" }    % (default)

% title の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.title.post.jp}
{ "」," }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	book 用 title

% book の title 前に付ける文字列 (英語文献用)
%
FUNCTION {bst.book.pre}
{ " {\it " }    % (default)

% book の title 後に付ける文字列 (英語文献用)
%
FUNCTION {bst.book.post}
{ "}" }    % (default)

% book の title 前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.book.pre.jp}
{ "『" }    % (default)

% book の title 後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.book.post.jp}
{ "』" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	booktitle

% booktitle の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.btitle.pre}
{ " {\it " }    % (default)

% booktitle の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.btitle.post}
{ "}" }    % (default)

% booktitle の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.btitle.pre.jp}
{ "『" }    % (default)

% booktitle の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.btitle.post.jp}
{ "』" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	journal name

% journal name の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.journal.pre}
{ " {\it " }    % (default)

% journal name の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.journal.post}
{ "}" }    % (default)

% journal name の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.journal.pre.jp}
{ "『" }    % (default)

% journal name の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.journal.post.jp}
{ "』" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	editor 記号

% 複数 editor を表す文字列 (英語文献用)
%
FUNCTION {bst.editors}
{ " eds. " }    % (default)

% 一人の editor を表す文字列 (英語文献用)
%
FUNCTION {bst.editor}
{ " ed. " }    % (default)

% editor を表す文字列 (日本語文献用)
%
FUNCTION {bst.editor.jp}
{ "(編)" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	edition

% edition の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.edition.pre}
{ ", " }    % (default)

% edition の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.edition.post}
{ " edition" }    % (default)

% edition の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.edition.pre.jp}
{ ",第" }    % (default)

% edition の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.edition.post.jp}
{ "版" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	volume

% volume の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.volume.pre}
{ ", Vol. " }    % (default)

% volume の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.volume.post}
{ "" }    % (default)

% volume の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.volume.pre.jp}
{ ",第" }    % (default)

% volume の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.volume.post.jp}
{ "巻" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	number

% number の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.number.pre}
{ ", No. " }    % (default)

% number の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.number.post}
{ "" }    % (default)

% number の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.number.pre.jp}
{ ",第" }    % (default)

% number の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.number.post.jp}
{ "号" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	in 

% In (英語文献用)
%
FUNCTION {bst.in}
{ " in " }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	page

% page の前に付ける文字列 (複数ページ) (英語文献用)
%
FUNCTION {bst.pages.pre}
{ ", pp." }    % (default)

% page の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.page.pre}
{ ", p." }    % (default)

% page の後に付ける文字列 (複数ページ) (英語文献用)
%
FUNCTION {bst.pages.post}
{ "" }    % (default)

% page の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.page.post}
{ "" }    % (default)

% page の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.page.pre.jp}
{ "," }    % (default)

% page の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.page.post.jp}
{ "頁" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	chapter

% chapter の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.chapter.pre}
{ ", Chap." }    % (default)

% chapter の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.chapter.post}
{ "" }    % (default)

% chapter の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.chapter.pre.jp}
{ ",第" }    % (default)

% chapter の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.chapter.post.jp}
{ "章" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	month

% month の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.month.pre}
{ ", " }    % (default)

% month の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.month.post}
{ "" }    % (default)

% month の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.month.pre.jp}
{ "," }    % (default)

% month の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.month.post.jp}
{ "月" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	address
% address の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.address.pre}
{ ", " }    % (default)

% address の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.address.post}
{ "" }    % (default)

% address の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.address.pre.jp}
{ "," }    % (default)

% address の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.address.post.jp}
{ "" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	publisher

% publisher の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.publisher.pre}
{ ": " }    % (default)

% publisher の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.publisher.post}
{ "" }    % (default)

% publisher の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.publisher.pre.jp}
{ "," }    % (default)

% publisher の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.publisher.post.jp}
{ "" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	series

% series の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.series.pre}
{ ", " }    % (default)

% series の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.series.post}
{ "" }    % (default)

% series の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.series.pre.jp}
{ "," }    % (default)

% series の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.series.post.jp}
{ "" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	organization

% organization の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.organization.pre}
{ ", " }    % (default)

% organization の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.organization.post}
{ "" }    % (default)
% organization の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.organization.pre.jp}
{ "," }    % (default)

% organization の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.organization.post.jp}
{ "" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	school

% school の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.school.pre}
{ ", " }    % (default)

% school の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.school.post}
{ "" }    % (default)

% school の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.school.pre.jp}
{ "," }    % (default)

% school の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.school.post.jp}
{ "" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	institution

% institution の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.institution.pre}
{ ", " }    % (default)

% institution の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.institution.post}
{ "" }    % (default)

% institution の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.institution.pre.jp}
{ "," }    % (default)

% institution の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.institution.post.jp}
{ "" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	howpublished

% howpublished の前に付ける文字列 (英語文献用)
%
FUNCTION {bst.howpublished.pre}
{ " " }    % (default)

% howpublished の後に付ける文字列 (英語文献用)
%
FUNCTION {bst.howpublished.post}
{ "" }    % (default)

% howpublished の前に付ける文字列 (日本語文献用)
%
FUNCTION {bst.howpublished.pre.jp}
{ "," }    % (default)

% howpublished の後に付ける文字列 (日本語文献用)
%
FUNCTION {bst.howpublished.post.jp}
{ "" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	邦訳書

FUNCTION {bst.hoyakusho.pre.jp}
{ "(" }    % (default)

FUNCTION {bst.hoyakusho.post.jp}
{ ")" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% 句点の指定.
FUNCTION {bst.kuten.jp}
{ "." }    % (default)

% 読点の指定.
FUNCTION {bst.touten.jp}
{ "," }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	
% 0 以外を指定すれば,page を繋ぐ "-" を "--" に変更しない.
FUNCTION {bst.dashify.off}
% { #0 }
{ #1 }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% 非ゼロを指定すると \harvarditem を出力しない.
FUNCTION {bst.harvarditem.off}
{ #0 }    % (default)
% { #1 }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	\thebibliography環境の定義
%
% thebibliography命令の前や後に何かを入れたいときは変更してください.
%
FUNCTION {bst.thebibliography.begin}
{
  "" write$ newline$
  "\begin{thebibliography}{xxx}" write$ newline$
  "" write$ newline$
}

FUNCTION {bst.thebibliography.end}
{ 
  "" write$ newline$
  "\end{thebibliography}" write$ newline$
  "" write$ newline$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	その他の関数

% Technical report を表す文字列 (英語文献用)
%
FUNCTION {bst.techrep}
{ " Tech. Rep." }    % (default)

% Technical report を表す文字列 (日本語文献用)
%
FUNCTION {bst.techrep.jp}
{ " テクニカル・レポート" }    % (default)

% master thesis を表す文字列 (英語文献用)
%
FUNCTION {bst.mthesis}
{ " Master's thesis" }    % (default)

% master thesis を表す文字列 (日本語文献用)
%
FUNCTION {bst.mthesis.jp}
{ "修士論文" }    % (default)

% phd thesis を表す文字列 (英語文献用)
%
FUNCTION {bst.phdthesis}
{ " Ph.D. dissertation" }    % (default)

% phd thesis を表す文字列 (日本語文献用)
%
FUNCTION {bst.phdthesis.jp}
{ "博士論文" }    % (default)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%	カスタマイズのための関数はここまで。
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% 以下は英語文献用

FUNCTION {bst.first}
{ "1st" }

FUNCTION {bst.second}
{ "2nd" }

FUNCTION {bst.third}
{ "3rd" }

FUNCTION {bst.fourth}
{ "4th" }

FUNCTION {bst.fifth}
{ "5th" }

FUNCTION {bst.st}
{ "st" }

FUNCTION {bst.nd}
{ "nd" }

FUNCTION {bst.rd}
{ "rd" }

FUNCTION {bst.th}
{ "th" }

%%%%% memo by Takeda

% "a" 'b := は b という変数に "a" という文字列を代入するということ。

% #0 は整数の 0、#1 は整数の 1...を表す。

%%% 関数の書式
%
% FUNCTION {name}
% { 's :=
%
% }
%
% 上は name という関数の定義。呼出し側では
%
% "hoge" name
%
% という形で指定。"hoge" という文字列が、変数 s に代入される。
%
% 引数が二つ以上の関数の定義 --> 関数 chop.word を参照。

ENTRY

  %%% 文献フィールドの宣言
  { address author booktitle chapter edition editor howpublished
    institution journal key month note number organization pages publisher
    school series title type volume year yomi

    % 以下は普通の bst ファイルでは利用されないフィールド
    jauthor jkanyaku jtitle jpublisher jyear
    order absorder
  }

  % 以下,エントリー変数の定義.エントリー変数とは,文献エントリー別に異なっ
  % た値を持つ変数のこと.

  %% これは entry 別の整数型変数 (整数型エントリ変数)
  { is.kanji.entry is.kanji.entry.two order.cited }

  %% これは entry 別の文字列型変数 (文字列型エントリ変数)
  { label cyear flabel alabel extra.label sort.label
    extra.label.bysame }

%%% 変数宣言

%% 文字列型大域変数
STRINGS { s t ss tt sss }
STRINGS { year.num }
STRINGS { num.kanji }
STRINGS { preone preten }
STRINGS { last.sort.label next.extra prev.author this.author }
STRINGS { hang }
STRINGS { item.type }

%% 整数型大域変数
INTEGERS { nameptr namesleft numnames  alphabet.in.author name.num }
INTEGERS { bysame.check }
INTEGERS { multiresult }
INTEGERS { index }
INTEGERS { len }
INTEGERS { last.extra.num }
INTEGERS { output.state before.all mid.sentence after.sentence after.block int }
INTEGERS { last.period.comma }

%%% 変数の説明

% alabel: 引用部分で利用される author (editor) 名 (省略形)を保持する変数. 
% reference 部分の表示には無関係.

% flabel: 引用部分で利用される author (editor) 名を保持する変数. reference 部
% 分の表示には無関係.

% sort.label: 文献のソートのための author (editor) 名を保持する変数.

% sort.key$: 文献のソート (並べ替え) のために利用される文字列を保持する.
% jecon.debug を非ゼロにすればどのような値が入っているか表示できる (通常は 
% author - year - title - month 等が繋った文字列が指定される).

%%% 汎用の関数の定義

FUNCTION {not}
{   { #0 }
    { #1 }
  if$
}

FUNCTION {and}
{   'skip$
    { pop$ #0 }
  if$
}

FUNCTION {or}
{   { pop$ #1 }
    'skip$
  if$
}

%%% 変数の値を初期化する関数
FUNCTION {init.state.consts}
{ #0 'before.all :=
  #1 'mid.sentence :=
  #2 'after.sentence :=
  #3 'after.block :=
}

%%% comma を除去し、period を付ける(に変える)関数 (英語文献用)
%
% #-1 #1 substring$ は後ろから一文字目を抜き出す処理をする。
%%%
FUNCTION {add.period.x}
{ duplicate$
  % 後ろから1文字とって比較
  #-1 #1 substring$ "," =
    { #-2 global.max$ substring$ "." * }
    { duplicate$
      % 後ろから2文字とって比較
      #-1 #2 substring$ ",'" =
        { #-3 global.max$ substring$ ".'" * }
        { duplicate$
          #-1 #2 substring$ ".'" =
            { #-3 global.max$ substring$ ".'" * }
            { duplicate$
              #-1 #2 substring$ ".~" =
                { #-3 global.max$ substring$ ".~" * }
                { duplicate$
                  #-1 #2 substring$ ",~" =
                    { #-3 global.max$ substring$ ".~" * }
                    { duplicate$
                      % 後ろから3文字とって比較
                      #-1 #3 substring$ ",''" =
                        { #-4 global.max$ substring$ ".''" * }
                        { duplicate$
                          #-1 #3 substring$ ".''" =
                            { #-4 global.max$ substring$ ".''" * }
                            { add.period$ }
                          if$
                        }
                      if$
                    }
                  if$
                }
              if$
            }
          if$
        }
     if$
   }
  if$
}

%%% "、" や "," を除去し、"." を付ける(に変える)関数 (日本語文献用)
FUNCTION {add.kanji.period.x}
{
  duplicate$
  % 後ろから1文字とって比較
  #-1 #1 substring$ "," =
    { #-2 global.max$ substring$ bst.kuten.jp * }
    { duplicate$
      % 後ろから1文字とって比較
      #-1 #1 substring$ "、" =
        { #-2 global.max$ substring$ bst.kuten.jp * }
        { duplicate$
          % 後ろから1文字とって比較
          #-1 #1 substring$ "." =
            {#-2 global.max$ substring$ bst.kuten.jp * }
	    {#-1 global.max$ substring$ bst.kuten.jp * }
          if$
        }
     if$
   }
  if$
}

%%% output.nonnull は文中なら前に ","、「,」を付ける。
FUNCTION {output.nonnull}
{ 's :=
  % mid.sentence のとき
  output.state mid.sentence =
    { is.kanji.entry
        { bst.touten.jp * write$ }
        { ", " * write$ }
      if$
    }
    % mid.sentence ではないとき
    { output.state after.block =
        % after.block のとき
	{ is.kanji.entry
            { add.kanji.period.x write$}
	    { add.period.x " " * write$ }
	  if$
	}
	% before.all のとき
	{ output.state before.all =
	    'write$
	    { is.kanji.entry
 		{ add.kanji.period.x write$ }
		{ add.period.x " " * write$ }
	      if$
	    }
	  if$
	}
      if$
      % mid.sentence 以外のときは mid.sentence に状態を変更。
      mid.sentence 'output.state :=
    }
  if$
  s
}

%%% 最後の文字が period or comma かどうかを判定。 period or comma の場合には
%%% last.period.comma に非ゼロを代入する。 
FUNCTION {period.comma.p}
{ duplicate$ 't :=
  t #-1 #1 substring$ "." = 
  t #-1 #1 substring$ "," = or
  t #-1 #1 substring$ "," = or 
  t #-1 #2 substring$ ".'" = or
  t #-1 #2 substring$ ",'" = or
  t #-1 #3 substring$ ".''" = or
  t #-1 #3 substring$ ",''" = or
  t #-1 #2 substring$ ".~" = or
  t #-1 #2 substring$ ",~" = or
  t #-1 #1 substring$ "。" = or
  t #-1 #1 substring$ "." = or
    { #1 'last.period.comma := }
    { #0 'last.period.comma := }
  if$
}

%%% 最初についている comma を除去した文字列を返す。
FUNCTION {remove.pre.comma}
{ 's :=
  s empty$
    { "" }
    { s #1 #1 substring$ "," = 
       { s #2 global.max$ substring$ }
       { s #1 #2 substring$ "," = s #1 #2 substring$ "、" = or
          { s #3 global.max$ substring$ }
          's
         if$
       }
      if$
    }
  if$
}

%%% output.nonnull.nocomma は文中でも前に ","、「,」を付けない。あとは 
%%% output.nonnull と全く同じ。
FUNCTION {output.nonnull.nocomma}
{ 's :=
  output.state mid.sentence =
    % mid.sentence のとき
    { period.comma.p
      "" * write$ }
 
    % mid.sentence ではないとき
    { output.state after.block =
        % after.block のとき
	{ is.kanji.entry
            { add.kanji.period.x write$}
	    { add.period.x " " * write$ }
	  if$
	}
	% before.all のとき
	{ output.state before.all =
	    'write$
	    { is.kanji.entry
 		{ add.kanji.period.x write$ }
		{ add.period$ " " * write$ }
	      if$
	    }
	  if$
	}
      if$
      % mid.sentence 以外のときは mid.sentence に状態を変更。
      mid.sentence 'output.state :=
    }
  if$
  % 直近の filed が period or comma で終わっているなら、その後の comma は除去する。
  last.period.comma #0 =
    { s }
    { s remove.pre.comma }
  if$
}

FUNCTION {output}
{ duplicate$ empty$
    'pop$
    'output.nonnull
  if$
}

FUNCTION {output.nocomma}
{ duplicate$ empty$
    'pop$
    'output.nonnull.nocomma
  if$
}
%%% output.nonnull にチェック機能を付加したもの。エントリーが空なら warning が
%%% 出力される。output.nonull なので、mid.sentence なら , を付ける。
FUNCTION {output.check}
{ 't :=
  duplicate$ empty$
    { pop$ "empty " t * " in " * cite$ * warning$ }
    'output.nonnull
  if$
}

%%% output.nonnull.nocomma にチェック機能を付加したもの。エントリーが空なら 
%%% warning が出力される。
FUNCTION {output.check.nocomma}
{ 't :=
  duplicate$ empty$
    { pop$ "empty " t * " in " * cite$ * warning$ }
    'output.nonnull.nocomma
  if$
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% bbl ファイルへの出力の形式

% \harvarditem[Brezis et~al.]{Brezis, Krugman and
%   Tsiddon}{1993}{brezis93:_leapf_inter_compet}
% Brezis, Elise~S., Paul~R. Krugman, and Daniel Tsiddon  (1993) ``Leapfrogging in
%   International Competition: A Theory of Cycles in National Technological
%   Leadership.'', {\em American Economic Review.}, Vol.~83. No.~5. pp.
%   1211--1219.

% \harvarditem[abbreviated citation]{full citation}{year}{keyword} ...
%
% という形式で出力する。

%%% period を付けて、改行する。
FUNCTION {fin.entry}
{ is.kanji.entry
    { add.kanji.period.x }
    { add.period.x }
  if$
  write$
  newline$
}

FUNCTION {new.block}
{ output.state before.all =
    'skip$
    { after.block 'output.state := }
  if$
}

FUNCTION {new.sentence}
{ output.state after.block =
    'skip$
    { output.state before.all =
	'skip$
	{ after.sentence 'output.state := }
      if$
    }
  if$
}

FUNCTION {new.block.check}
{ empty$
    'skip$
    'new.block
  if$
}

FUNCTION {field.or.null}
{ duplicate$ empty$
    { pop$ "" }
    'skip$
  if$
}

%%% booktitle の整形。
FUNCTION {format.btitle}
{ booktitle empty$
    { "" }
    { booktitle is.kanji.str$
	{ bst.btitle.pre.jp booktitle * bst.btitle.post.jp * }
	{ bst.btitle.pre booktitle * bst.btitle.post * }
      if$
    }
  if$
}

%%% journal の整形。
FUNCTION {format.journal}
{ journal empty$
    { "" }
    { journal is.kanji.str$
	{ bst.journal.pre.jp journal * bst.journal.post.jp * }
 	{ bst.journal.pre journal * bst.journal.post * }
      if$
    }
  if$
}

%%% book の title の整形。
FUNCTION {format.book}
{ title empty$
    { "" }
    { title is.kanji.str$
	{ bst.book.pre.jp title * bst.book.post.jp * }
 	{ bst.book.pre title * bst.book.post * }
      if$
    }
  if$
}

%%% 以下、author, editor の処理

% 日本語 author 名のときに alphabet が含まれているかどうか判断する関数。含まれ
% ているなら alphabet.in.author に 1 を代入、含まれていないなら 0 を代入。これ
% は Alphabet + 片仮名の外国人名を処理するためのもの。
FUNCTION {set.alphabet.in.author}
{ name.num "{ff}" format.name$ 't :=
  #0 'alphabet.in.author :=
  "" t =
    % first name がないときは 0。
    { #0 'alphabet.in.author := }
    { 
      % 記号除去
      t purify$ 't :=
      % 一文字目だけ取り出す。
      t #1 text.prefix$ 't :=
      % 日本語か alphabet か?
      t is.kanji.str$
        { #0 'alphabet.in.author :=
        }
        { #1 'alphabet.in.author :=
        }
      if$
    }
  if$
}

%%% 文字の数を判断する関数 (日本語用)。
% 日本語の場合 1 文字が 2 文字と判断されることに注意。
FUNCTION {count.number.of.letters}
{ 'sss :=
   sss text.length$ #2 =
      % 一文字のケースでは "1" を返す。
      { "1" }
      % 一文字以外のケースでは "0" を返す。
      { "0" }
   if$
}

%%% name を処理する関数
FUNCTION {format.names}
{ 's :=
  % nameptr に 1 を代入
  #1 'nameptr :=
  % numnames に author (editor) の数を代入
  s num.names$ 'numnames :=
  numnames 'namesleft :=
  % namesleft が 0 より大なら繰り返し (while)
  { namesleft #0 > }
    % s に日本語含むか?
    { s is.kanji.str$
        % 日本語含むケースの処理
        { nameptr 'name.num :=
          s set.alphabet.in.author
          alphabet.in.author #0 =
            % first name も日本語のケース

            % 注:日本語の author は "姓 名" の順で指定されるが、bst では
            % 順番通りに姓=first name、名=last name として扱われる。
            { s nameptr "{ff}" format.name$ 'ss :=
              s nameptr "{ll}" format.name$ 'tt :=
              ss "" =
                %% 姓のみのケースはそのまま
                { tt 't := }
                %% 姓・名ともにあるケース
                { ss count.number.of.letters "1" =
                  tt count.number.of.letters "1" = or
                    { ss bst.sei.mei.one.jp * tt * 't := }
                    { ss bst.sei.mei.two.jp * tt * 't := }
                  if$
                }
              if$
            }
            % first name が alphabet のケース (つまり、カタカナの外国人名)
            { nameptr #1 =
               % first author のケース (last name - first name の order)
               { bst.author.name #0 =
                 bst.author.name #1 = or
                   % Last name - first name
                   { s nameptr "{ll}" format.name$ 'ss :=
                     s nameptr "{ff}" format.name$ 'tt :=
                     ss bst.touten.jp * tt * 't := }
                   % First name - Last name
                   { s nameptr "{ff~}{ll}" format.name$ 't := }
                 if$
               }
               % first author 以外のケース (first name - last name の order)
               { bst.author.name #0 =
                 bst.author.name #2 = or
                   % First name - Last name
                   { s nameptr "{ff~}{ll}" format.name$ 't := }
                   % Last name - First name
                   { s nameptr "{ll}" format.name$ 'ss :=
                     s nameptr "{ff}" format.name$ 'tt :=
                     ss bst.touten.jp * tt * 't := }
                 if$
               }
              if$
            }
          if$
        }
        % author に日本語含まないケースの処理
        { nameptr #1 =
           % 一番目の author
	   { bst.author.name #0 =
	     bst.author.name #1 =
	     or
	        { bst.first.name.initial #0 = 
		   { s nameptr "{vv~}{ll}{, ff}{, jj}" format.name$ 't := }
		   { s nameptr "{vv~}{ll}{, f.}{, jj}" format.name$ 't := }
		  if$
		}
	        { bst.first.name.initial #0 = 
	           { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't := }
	           { s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't := }
		  if$
		}
	     if$
	   }
           % 二番目以降の author
	   { bst.author.name #0 =
	     bst.author.name #2 =
	     or
	        { bst.first.name.initial #0 = 
                   { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't := }
                   { s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't := }
		 if$
	        }
	        { bst.first.name.initial #0 = 
   	           { s nameptr "{vv~}{ll}{, ff}{, jj}" format.name$ 't := }
   	           { s nameptr "{vv~}{ll}{, f.}{, jj}" format.name$ 't := }
		 if$
	        }
	     if$
	   }
          if$
        }
      if$
      nameptr #1 >
        % 二番目以降の author のケースでの処理
	{ namesleft #1 >
 	    { s is.kanji.str$
 		{ bst.and.jp  * t * }
 		{ ", " * t * }
	      if$
	    }
	    { t "others" =
  		{ s is.kanji.str$
  		    { bst.and.others.jp * }
                    { bst.and.others * }
 		  if$
 		}
  		{ s is.kanji.str$
 		    { bst.and.jp * t * }
		    { numnames #2 =
  			{ bst.and * t * }
  			{ bst.ands * t * }
		      if$
		    }
 		   if$
 		}
	      if$
	    }
	  if$
	}
	't
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
}

%%% author の整形
FUNCTION {format.authors}
{ author empty$
    { "" }
    { extra.label.bysame "bysame" =
	{"\bysame "}
 	{ author is.kanji.str$
 	    { bst.author.pre.jp author format.names * bst.author.post.jp * }
   	    { bst.author.pre author format.names * bst.author.post * }
	  if$
	}
      if$
    }
  if$
}

%%% editor の整形
FUNCTION {format.editors}
{ editor empty$
    { "" }
    { extra.label.bysame "bysame" =
	{ #1 'bysame.check :=
	   "\bysame " }
	{ editor is.kanji.str$
	    { bst.author.pre.jp editor format.names * }
 	    { bst.author.pre editor format.names * bst.author.post * }
	  if$
	}
      if$
      #1 bysame.check =
        { "" * }
        { editor num.names$ #1 >
 	  { editor is.kanji.str$
              { bst.editor.jp * }
	      { bst.editors * }
	    if$
 	  }
  	  { editor is.kanji.str$
 	      { bst.editor.jp * }
	      { bst.editor * }
	    if$
 	  }
        if$
        }
      if$
    }
  if$
}

%%% format.in.ed.booktitle 用
FUNCTION {format.editors.x}
{ editor empty$
    { "" }
    { editor format.names
      editor num.names$ #1 >
 	{ editor is.kanji.str$
 	    { bst.editor.jp * }
	    { bst.editors * }
	  if$
 	}
  	{ editor is.kanji.str$
 	    { bst.editor.jp * }
	    { bst.editor * }
	  if$
 	}
      if$
    }
  if$
}

%%% 「?.」、「?,」のようなケースで、period、comma を除去する関数
FUNCTION {remove.irrelevant.period.comma}
{ 's :=
  s empty$
    { "" }
    % 後ろから3文字とって比較
    { s #-1 #3 substring$ "?,'" =
      s #-1 #3 substring$ "?.'" = or
        % 後ろから3文字を除いたものに "'" を付ける.
        { s #-3 global.max$ substring$ "'" * }
	{ s #-1 #4 substring$ "?,''" =
          s #-1 #4 substring$ "?.''" = or
            { s #-4 global.max$ substring$ "''" * }
	    { s #-1 #2 substring$ "?," =
              s #-1 #2 substring$ "?." = or
                { s #-2 global.max$ substring$ "" * }
                { s #-1 #3 substring$ "?,~" =
                  s #-1 #3 substring$ "?.~" = or
                    { s #-4 global.max$ substring$ "?~" * }
                    's
                  if$
                }
	      if$
            }
          if$
        }
      if$
    }
  if$
}

%%% 最後についているの「,」、「、」、「.」、「.」を除去する関数 (邦訳書用)
FUNCTION {remove.irrelevant.kutoten}
{ 's :=
  s empty$
    { "" * }
    { s #-1 #1 substring$ "、" =
      s #-1 #1 substring$ "," = or
      s #-1 #1 substring$ "。" = or
      s #-1 #1 substring$ "." = or
        { s #-2 global.max$ substring$ "" * }
        { s }
      if$
    }
  if$
}

%%% title の整形
FUNCTION {format.title.sub}
{ bst.title.lower.case #0 =
     { bst.title.pre title * bst.title.post * }
     { bst.title.pre title "t" change.case$ * bst.title.post * }
  if$
}

%%% title の整形
FUNCTION {format.title}
{ title empty$
    { "" }
    { title is.kanji.str$
      { bst.title.pre.jp title * bst.title.post.jp * }
      { format.title.sub remove.irrelevant.period.comma }
     if$
    }
  if$
}

%%% jtitle の整形
FUNCTION {format.jtitle}
{ jtitle empty$
    { "" }
    { bst.book.pre.jp jtitle * bst.book.post.jp * }
  if$
}

%%% misc の title の処理
FUNCTION {format.misc.title}
{ title empty$
    { "" }
    { title is.kanji.str$
      { bst.title.pre.jp title * bst.title.post.jp * }
      { bst.title.pre title * bst.title.post * }
     if$
    }
  if$
}

% - を -- にする関数 (pages 用)
FUNCTION {n.dashify}
{ 't :=
  ""
  %% while$ の条件 (t が empty でないなら実行)
  { t empty$ not }
  %% 処理
  { t #1 #1 substring$ "-" =
      { t #1 #2 substring$ "--" = not
          { bst.dashify.off
              { "-" * }
              { "--" * }
            if$
            t #2 global.max$ substring$ 't :=
          }
          { { t #1 #1 substring$ "-" = }
            { "-" *
              t #2 global.max$ substring$ 't :=
            }
            while$
          }
        if$
      }
      { t #1 #1 substring$ is.kanji.str$
        { t #1 #2 substring$ *
          t #3 global.max$ substring$ 't :=
        }
         { t #1 #1 substring$ *
          t #2 global.max$ substring$ 't :=
        }
        if$
      }
    if$
  }
  while$
}

%%% 与えられた数を漢数字に変換: 0->〇, 1->一, 2->二,..., 9->九 という対応関係。
%%% さらに、"-" は縦棒に変換する。
FUNCTION {convert.num.kanji}
{ 's :=
  s "1" =
    { "一" }
    { s "2" =
        { "二" }
        { s "3" =
            { "三" }
            { s "4" =
                { "四" }
                { s "5" =
                    { "五" }
                    { s "6" =
                        { "六" }
                        { s "7" =
                            { "七" }
                            { s "8" =
                                { "八" }
                                { s "9" =
                                    { "九" }
                                    { s "0" =
                                        { "〇" }
                                        { s "-" =
                                           { "\tatebo{}" }
                                           { s }
                                          if$
                                        }
                                      if$
                                    }
                                if$
                                }
                            if$
                            }
                        if$
                        }
                    if$
                    }
                if$
                }
            if$
            }
        if$
        }
    if$
    }
  if$
}

%%% 半角の alphabet を全角の alphabet に変更する関数 (a-j までのみ)。
FUNCTION {convert.alphabet.zenkaku}
{ 's :=
  s "a" =
    { "a" }
    { s "b" =
        { "b" }
        { s "c" =
            { "c" }
            { s "d" =
                { "d" }
                { s "e" =
                    { "e" }
                    { s "f" =
                        { "f" }
                        { s "g" =
                            { "g" }
                            { s "h" =
                                { "h" }
                                { s "i" =
                                    { "i" }
                                    { s "j" =
                                        { "j" }
                                        { s }
                                    if$
                                    }
                                if$
                                }
                            if$
                            }
                        if$
                        }
                    if$
                    }
                if$
                }
            if$
            }
        if$
        }
    if$
    }
  if$
}

%%% year を漢数字に変換
FUNCTION{convert.year.kanji}
{ 't :=
  %% bst.kansuji.jp が非ゼロでかつ,t が漢字じゃないのなら,漢字に変換
  bst.kansuji.jp #0 = not t is.kanji.str$ not and 
     { "" 'tt :=
       { t empty$ not }
       { tt t #1 #1 substring$ convert.num.kanji convert.alphabet.zenkaku * 'tt :=
         t #2 global.max$ substring$ 't := }
       while$
     }
     { t 'tt := }
  if$
 tt
}

%%% bst.kansuji.jp が非ゼロのとき、数字を漢数字に変換する関数。
FUNCTION{convert.num}
{ 't :=
  bst.kansuji.jp #0 = t is.kanji.str$ or
     { t 'tt := }
     { "" 'tt :=
       { t empty$ not }
       { t #1 #1 substring$ convert.num.kanji 'ss :=
         tt ss * 'tt :=
         t #2 global.max$ substring$ 't :=
         }
       while$
     }
  if$
 tt
}

%% 変数定義
STRINGS { da db dc dd }
%% pages の "--" を "-" に変換する.
FUNCTION {remove.duplicate.dash}
{ 'da :=
  "" 'db :=
  "" 'dc :=
  "" 'dd :=
  { da empty$ not }
  { da #1 #1 substring$ 'db :=
    db "-" = dc "-" = and
       'skip$
       { dd db * 'dd := }
    if$
    db 'dc :=
    da #2 global.max$ substring$ 'da :=
  }
  while$
  dd
}

%%% bst.kansuji.jp が非ゼロのとき、pages を漢数字に変換する関数。
FUNCTION{convert.num.pages}
{ 't :=
  bst.kansuji.jp #0 = t is.kanji.str$ or
     { t 'tt := }
     { "" 'tt :=
       t remove.duplicate.dash 't :=
       { t empty$ not }
       { t #1 #1 substring$ convert.num.kanji 'ss :=
         tt ss * 'tt :=
         t #2 global.max$ substring$ 't :=
         }
       while$
     }
  if$
 tt
}

%%% year の処理
FUNCTION {format.year}
{ year empty$
    { "there's no year in " cite$ * warning$
      "" }
    { is.kanji.entry
        { bst.kansuji.jp #0 =
           { bst.year.pre.jp year * extra.label * bst.year.post.jp * }
           { bst.year.pre.jp year convert.year.kanji *
             extra.label convert.alphabet.zenkaku * bst.year.post.jp * }
          if$
        }
        { bst.year.pre year * extra.label * bst.year.post * }
      if$
    }
  if$
}

%%% book の page の処理
FUNCTION {format.book.pages}
{ pages empty$
    { "" }
    { is.kanji.entry
        { bst.page.pre.jp pages convert.num.pages * bst.page.post.jp * }
        { bst.pages.pre pages * bst.pages.post * }
      if$
    }
  if$
}

%%% 2文字以下なら前に tie を付ける.
FUNCTION {tie.or.space.connect}
{ duplicate$ text.length$ #3 <
    { "~" }
    { " " }
  if$
  swap$ * *
}

FUNCTION {either.or.check}
{ empty$
    'pop$
    { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  if$
}

%%% book の volume の整形
FUNCTION {format.bvolume}
{ volume empty$
    { "" }
    { is.kanji.entry
	{ bst.volume.pre.jp volume convert.num * bst.volume.post.jp * }
        { bst.volume.pre volume * bst.volume.post * }
      if$
      series empty$
	'skip$
	%% series もあるとき
	{ is.kanji.entry
	    { bst.series.pre.jp * series convert.num * bst.series.post.jp * }
	    { " of " * series * bst.series.post * }
	  if$
	}
      if$
%       "volume and number" number either.or.check
    }
  if$
}

%%% series の出力
FUNCTION {output.series}
{ series empty$
    { "" }
    { is.kanji.entry
        { bst.series.pre.jp series convert.num * bst.series.post.jp * }
        { bst.series.pre series * bst.series.post * }
      if$
    }
 if$
}

%%% number と series を出力
FUNCTION {format.number.series}
{ volume empty$
    { number empty$
      bst.hide.number #0 = not or
        % number is empty
   	{ series empty$
	    { "" }
	    % series is not empty.
	    { output.series }
	  if$
	}
        % number is not empty$
	{ series empty$
	    { is.kanji.entry
	        { bst.number.pre.jp number convert.num * bst.number.post.jp * }
		{ bst.number.pre number * bst.number.post * }
	      if$
	    }
	    % series is not empty.  日本語と英語で順序逆にする。
	    { is.kanji.entry
 	        { bst.series.pre.jp series convert.num * bst.series.post.jp *
		  bst.number.pre.jp * number convert.num * bst.number.post.jp * }
		{ bst.in bst.series.pre * series * bst.series.post *
		  bst.number.pre * number * bst.number.post * }
	      if$
	    }
	  if$
	}
      if$
    }
    { "" }
  if$
}

%%% 数字かどうか判断する
FUNCTION {is.num}
{ chr.to.int$
  duplicate$ "0" chr.to.int$ < not
  swap$ "9" chr.to.int$ > not and
}

FUNCTION {extract.num}
{ duplicate$ 't :=
  "" 's :=
  { t empty$ not }
  { t #1 #1 substring$
    t #2 global.max$ substring$ 't :=
    duplicate$ is.num
      { s swap$ * 's := }
      { pop$ "" 't := }
    if$
  }
  while$
  s empty$
    'skip$
    { pop$ s }
  if$
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%	edition 処理用のプログラム

% 英語の edition は全て 1st, 2nd, 3rd, 4th etc. に変換する。
FUNCTION {eng.ord}
{ duplicate$ "1" swap$ *
  #-2 #1 substring$ "1" =
     { bst.th * }
     { duplicate$ #-1 #1 substring$
       duplicate$ "1" =
         { pop$ bst.st * }
         { duplicate$ "2" =
             { pop$ bst.nd * }
             { "3" =
                 { bst.rd * }
                 { bst.th * }
               if$
             }
           if$
          }
       if$
     }
   if$
}

% edition entry の first, second 等を 1st, 2nd に変換する (from jfm.bst)。
FUNCTION {convert.edition}
{ edition extract.num "l" change.case$ 's :=
  s "first" = s "1" = or
    { bst.first }
    { s "second" = s "2" = or
        { bst.second }
        { s "third" = s "3" = or
            { bst.third }
            { s "fourth" = s "4" = or
                { bst.fourth }
                { s "fifth" = s "5" = or
                    { bst.fifth }
                    { s #1 #1 substring$ is.num
                        { s eng.ord }
                        { edition }
                      if$
                    }
                  if$
                }
              if$
            }
          if$
        }
      if$
    }
  if$
}

% 日本語文献の場合には英語の月を数字に変換する。
FUNCTION {