[Tex/LaTex] Modifying bst file – changing separator

bibtex

I am currently modifying a bst file. The problem I am facing now is how to change the separator of the style.

At the moment, I get the following output:

Badie, Dina (2010) ‘Groupthink, iraq, and the war on terror: Explaining us policy shifts toward iraq’ Foreign Policy Analysis 6(4):277–296.

However, I need the following output:

Badie, Dina (2010) ‘Groupthink, iraq, and the war on terror: Explaining us policy shifts toward iraq’, Foreign Policy Analysis 6(4):277–296.

With NO comma after the year, but WITH a comma after the title (and after the editor in a chapter of an edited volume).

Here is the code of the bst file:

FUNCTION {output.nonnull}
{ 's :=
  output.state mid.sentence =
    { ", " * write$ }
    { output.state after.block =
        %{ add.period$ write$
        { " " * write$
          newline$
          "\newblock " write$
        }
        { output.state before.all =
            'write$
            { add.period$ " " * write$ }
          if$
        }
      if$
      mid.sentence 'output.state :=
    }
  if$
  s
}

FUNCTION {article}
{ output.bibitem
  format.authors "author" output.check
  author format.key output
  format.date "year" output.check
  date.block
  format.title quote "title" output.check
  new.block
  crossref missing$
    {
      journal
      "journal" bibinfo.check

      "journal" output.check
      add.blank
      format.vol.num.pages output
    }
    { format.article.crossref output.nonnull
      format.pages output
    }
  if$
  new.block
  format.note output
  fin.entry
}

FUNCTION {format.title}
{ title
  duplicate$ empty$ 'skip$
    { "t" change.case$ }
  if$
  "title" bibinfo.check
}

Best Answer

I tried to solve the problem on my own. So I modified the @article function by changing

format.title quote "title" output.check

to

format.title ", " * quote "title" output.check

Here is the complete function

FUNCTION {article}
{ output.bibitem
  format.authors "author" output.check
  author format.key output
  format.date "year" output.check
  date.block
  format.title ", " * quote "title" output.check
  new.block
  crossref missing$
    {
      journal
      "journal" bibinfo.check
      emphasize
      "journal" output.check
      add.blank
      format.vol.num.pages output
    }
    { format.article.crossref output.nonnull
      format.pages output
    }
  if$
  new.block
  format.note output
  fin.entry
}

The result looks like this:

Burke, John P. (2005a) ‘Condoleezza Rice as NSC Advisor: A Case of the Honest Broker Role, ’ Presidential Studies Quarterly 35(3): 554–575.

However, I want the comma to be outside the quote, as follows:

Burke, John P. (2005a) ‘Condoleezza Rice as NSC Advisor: A Case of the Honest Broker Role’, Presidential Studies Quarterly 35(3): 554–575.

How can I solve that Problem? Maybe by changing the quote function?

FUNCTION {quote}
{ duplicate$ empty$
    { pop$ "" }
    { "`" swap$ * "'" * }
  if$
}