% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% --------------------------------------------------------------
%% Based on the gost package styles by
%% Maksym Polyakov      © 1996-2005, 
%% Leonid Sinev         © 2017,
%% Igor A. Kotelnikov   © 2012-2021.
%% --------------------------------------------------------------
%% Alexey V. Kuznetsov: mailtokuznetsov@gmail.com
%% Brief citation style
%% Version 1
%% --------------------------------------------------------------

ENTRY{
  address         % alias for location
  archivePrefix   % alias for eprinttype
  author
  booktitle
  chapter
  compiler
  date
  doi
  edition
  editor
  eid
  eprint
  eprinttype      % alias for archivePrefix
  eprintclass     % alias for primaryClass
  howpublished
  institution     % alias for organization and school
  ipc
  isbn
  issn
  journal
  key
  language        % alias for langid
  langid          % alias for language
  location        % alias for address
  media
  note
  number
  organization    % alias for institution and school
  origlanguage
  pages
  primaryClass    % alias for eprintclass
  prioritycountry
  publisher
  school          % alias for institution and organization
  series
  title
  translator
  type
  url
  urldate
  volume
  year
  }{}{label}

INTEGERS{
  output.state
  before.all
  mid.sentence
  after.sentence
  after.block
  after.dblslash
  after.slash
  after.colon
  after.semicolon }

STRINGS{curlanguage}
STRINGS{s t}
STRINGS{y m d}

FUNCTION{init.state.consts}{
  #0 'before.all :=
  #1 'mid.sentence :=
  #2 'after.sentence :=
  #3 'after.block :=
  #4 'after.dblslash :=
  #5 'after.slash :=
  #6 'after.colon :=
  #7 'after.semicolon := }

FUNCTION {set.language}{
  langid empty$
    {language empty$ {"english" 'curlanguage :=} {language  'curlanguage :=} if$}
    {langid  'curlanguage :=}
  if$}

FUNCTION{output.nonnull}{
  swap$
  output.state mid.sentence    = {", " * write$}
 {output.state after.block     = {add.period$ write$ "~\BibDash " write$ newline$ "\newblock " write$}
 {output.state before.all      = 'write$
 {output.state after.dblslash  = {"~/\!/ " * write$}
 {output.state after.slash     = {"~/ " * write$}
 {output.state after.colon     = {"~: " * write$}
 {output.state after.semicolon = {"~; " * write$} {add.period$ " " * write$}
  if$}if$}if$}if$}if$}if$
  mid.sentence 'output.state := }
  if$}

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

FUNCTION{fin.entry}{add.period$ "\endgroup" * write$ newline$}
FUNCTION{add.blank}    {" " * before.all 'output.state :=}
FUNCTION{new.block}    {output.state before.all  = 'skip$ {after.block     'output.state :=} if$}
FUNCTION{new.dblslash} {output.state before.all  = 'skip$ {after.dblslash  'output.state :=} if$}
FUNCTION{new.slash}    {output.state before.all  = 'skip$ {after.slash     'output.state :=} if$}
FUNCTION{new.colon}    {output.state before.all  = 'skip$ {after.colon     'output.state :=} if$}
FUNCTION{new.semicolon}{output.state before.all  = 'skip$ {after.semicolon 'output.state :=} if$}
FUNCTION {new.sentence}{output.state after.block = 'skip$
  {output.state before.all = 'skip$ {after.sentence 'output.state :=} if$} if$}

FUNCTION{not}{{#0} {#1} if$}
FUNCTION{and}{'skip$ {pop$ #0} if$}
FUNCTION{or} {{pop$ #1} 'skip$ if$}

FUNCTION{bracify}      {duplicate$ empty$ {pop$ ""} {"{" swap$ * "}" *}      if$}
FUNCTION{bracketise}   {duplicate$ empty$ {pop$ ""} {"[" swap$ * "]" *}      if$}
FUNCTION{paranthesify} {duplicate$ empty$ {pop$ ""} {"(" swap$ * ")" *}      if$}
FUNCTION{emphasize}    {duplicate$ empty$ 'skip$ {"\emph{" swap$ * "}" *} if$}

FUNCTION{thinspace.connect}{"\," swap$ * *}

FUNCTION{n.dashify}{
  't := ""
  {t empty$ not}
    {t #1 #1 substring$ "-" =
       {t #1 #2 substring$ "--" = not
          {"--" * t #2 global.max$ substring$ 't :=}
          {{t #1 #1 substring$ "-" =}
              {"-" * t #2 global.max$ substring$ 't :=}
           while$}
        if$}
       {t #1 #1 substring$ * t #2 global.max$ substring$ 't :=}
     if$}
  while$}

INTEGERS{multiresult nameptr namesleft numnames}

FUNCTION{bbl.etal}{
  curlanguage "english"   = {" \textup{[et al.]}"}
 {curlanguage "german"    = {" \textup{[u. a.]}"}
 {curlanguage "ukrainian" = {" \textup{[та ін.]}"}
 {curlanguage "russian"   = {" \textup{[и др.]}"}
 {"language is not defined: " curlanguage  " in bbl.etal" * * warning$ " \textup{[et al.]}"}
 if$}if$}if$}if$}

FUNCTION{bbl.and}{
  curlanguage "english"   = {" and "}
 {curlanguage "german"    = {" und "}
 {curlanguage "ukrainian" = {"~i "}
 {curlanguage "russian"   = {author empty$ {"~и "} {s author = not {"~и "} {", "} if$} if$}
 {"language is not defined: " curlanguage  " in bbl.and" * * warning$ " and "}
 if$}if$}if$}if$}

FUNCTION{fmt.names.three}{
  's :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
  {namesleft #0 >}
     {s nameptr "{vv~}{ll}{~jj}{~ff}"
      format.name$ 't :=
      nameptr #1 >
        {nameptr #4 = numnames #4 > and {"others" 't :=  #1 'namesleft :=} 'skip$ if$
         namesleft #1 >
           {", " * t *} {t "others" = t "~others" = or {bbl.etal *} {bbl.and t * *} if$}
         if$}
        't
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=}
  while$}

FUNCTION{fmt.names}{
  's :=
  #1 'nameptr :=
  s num.names$ 'namesleft :=
  {namesleft #0 >}
     {s nameptr "{vv~}{ll}{~jj}{~ff}"
      format.name$ 't :=
      nameptr #1 > not 't {namesleft #1 > {", " * t *} {bbl.and t * *} if$} if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=}
  while$}

FUNCTION{format.names}{
  's :=
  s empty$ {""}
    {s num.names$ #4 > {s fmt.names.three} {s fmt.names} if$}
  if$}

FUNCTION{format.authors}   {author     empty$ {""} {author     format.names} if$}

FUNCTION{output.bibitem}{
  set.language
  newline$ "\bibitem" write$
  cite$ bracify write$
  newline$ "\begingroup\selectlanguageifdefined" curlanguage bracify * write$
  newline$ ""
  before.all 'output.state :=}

FUNCTION{format.date}{
  year empty$
    {date empty$ {""}
       {date text.length$ #4 < 
         {"wrong format of date in " cite$ * ": date=" * date * warning$ ""}
         {curlanguage "russian" = 
            {date date text.length$ #3 - date text.length$ substring$}
            {date #1 #4 substring$}
     if$}if$}if$}
    'year
  if$}

FUNCTION{bbl.vol}{
  curlanguage "english" = {"Vol."}
 {curlanguage "german"  = {"Bd."} 
 {curlanguage "russian" = curlanguage "ukrainian" = or {"Т."}
 {"language is not defined: " curlanguage " in bbl.vol" * * warning$ "Vol."}
 if$}if$}if$}

FUNCTION{format.volume}{volume empty$ {""} {bbl.vol volume thinspace.connect} if$}

FUNCTION {bbl.nr}{
  curlanguage "english" = {"no."}
 {curlanguage "german"  = {"nr."} 
 {curlanguage "russian" = curlanguage "ukrainian" = or {"№"}
 {"language is not defined: " curlanguage " in bbl.no" * * warning$ "no."}
 if$}if$}if$}

FUNCTION {bbl.No}{
  curlanguage "english" = {"No."}
 {curlanguage "german"  = {"Nr."} 
 {curlanguage "russian" = curlanguage "ukrainian" = or {"№"}
 {"language is not defined: " curlanguage " in bbl.No" * * warning$ "No."}
 if$}if$}if$}

FUNCTION{format.number}{
  number empty$ {""} 
    {volume empty$ 'bbl.No 'bbl.nr if$ number thinspace.connect}
  if$}

FUNCTION{bbl.chapter}{
  curlanguage "english" = {"Сh."}
 {curlanguage "german"  = {"Kap."}
 {curlanguage "russian" = curlanguage "ukrainian" = or {"Гл."}
 {"language is not defined: " curlanguage " in bbl.chapter" * * warning$ "Ch."}
 if$}if$}if$}

FUNCTION{chapter.type}{
  chapter empty$ {""}
    {type empty$ 'bbl.chapter 'type if$ chapter thinspace.connect}
  if$}

FUNCTION{bbl.pages}{
  curlanguage "english" = {"P."} 
 {curlanguage "german"  = {"S."}
 {curlanguage "russian" = curlanguage "ukrainian" = or {"С."}
 {"language is not defined: " curlanguage " in bbl.pages" * * warning$ "P."}
 if$}if$}if$}

FUNCTION{multi.page.check}{
  't :=
  #0 'multiresult :=
  {multiresult not t empty$ not and}
     {t #1 #1 substring$
      duplicate$ "-" = swap$ duplicate$ "," = swap$ "+" = or or
        {#1 'multiresult :=} {t #2 global.max$ substring$ 't :=} if$}
  while$
  multiresult}

FUNCTION{format.pages}{
  pages empty$
    {type$ "inbook" = type$ "incollection" = or 'chapter.type {""} if$}
    {pages multi.page.check {pages n.dashify} 'pages if$
     bbl.pages swap$  thinspace.connect}
  if$}

FUNCTION{format.eid.pages}{
  eid empty$ not 'eid {pages empty$ {""} 'format.pages if$} if$}

INTEGERS{link.exists}
  
FUNCTION{open.link}{
  #0 'link.exists :=
  doi  empty$ not {#1 'link.exists := "\href{https://doi.org/" doi "}{" * *}
 {url  empty$ not {#1 'link.exists := "\href{" url "}{" * *}
 {type$ "book" = type$ "inbook" = type$ "incollection" = type$ "booklet" =
  type$ "proceedings" = type$ "inproceedings" = or or or or or isbn empty$ not and
    {#1 'link.exists := "\href{https://isbnsearch.org/isbn/" isbn "}{" * *}
 {type$ "article" = type$ "proceedings" = type$ "inproceedings" = or or issn empty$ not and
    {#1 'link.exists := "\href{https://portal.issn.org/search?search=" issn "}{" * *} {""}
 if$}if$}if$}if$}

FUNCTION{close.link}{link.exists #0 > {"}"} {""} if$}

FUNCTION{author.or.title}{
  author empty$ title empty$ and {""}
    {author empty$ {title 's :=} {format.authors emphasize 's :=} if$
     type$ "article" = {open.link s close.link * *} 's if$}
  if$}

FUNCTION{check.author}   {author      empty$ {"empty author in "    cite$ * warning$} 'skip$ if$}
FUNCTION{check.title}    {title       empty$ {"empty title in "     cite$ * warning$} 'skip$ if$}
FUNCTION{check.year}     {format.date empty$ {"empty year in "      cite$ * warning$} 'skip$ if$}
FUNCTION{check.publisher}{publisher   empty$ {"empty publisher in " cite$ * warning$} 'skip$ if$}  
FUNCTION{check.booktitle}{booktitle   empty$ {"empty booktitle in " cite$ * warning$} 'skip$ if$}
FUNCTION{check.type}     {type        empty$ {"empty type in "      cite$ * warning$} 'skip$ if$}

FUNCTION{check.journal}{
  journal empty$ {"empty journal in " cite$ * warning$} 'skip$ if$
  check.author check.year} 

FUNCTION{article}{
  output.bibitem   check.journal
  author.or.title  output new.dblslash
  journal          output
  series           output new.sentence
  format.date      output new.sentence
  format.volume    output       
  format.number    output new.sentence       
  format.eid.pages output fin.entry}

FUNCTION{org.inst.school}{
  organization empty$ {institution empty$ 'school 'institution if$} 'organization if$}

FUNCTION{check.auth.org}{
  type$ "book" = type$ "inbook" = or
    {author empty$ {""} {author num.names$ #4 < {""} {"no"} if$} if$}
 {type$ "booklet"  = not 'org.inst.school
    {author empty$ 'org.inst.school {author num.names$ #4 < 'org.inst.school {"no"}
  if$}if$}if$}if$}

FUNCTION{bbl.compiler}{
  curlanguage "english"   = {check.auth.org empty$ {"Comp. "} {"comp. "} if$}
 {curlanguage "german"    = {check.auth.org empty$ {"Hrsg. "} {"hrsg. "} if$}
 {curlanguage "ukrainian" = {check.auth.org empty$ {"Укл. "} {"укл. "} if$}
 {curlanguage "russian"   = {check.auth.org empty$ {"Сост. "} {"сост. "} if$}
 {"language is not defined: " curlanguage  " in bbl.compiler" * * warning$ 
  check.auth.org empty$ {"Comp. "} {"comp. "}
 if$}if$}if$}if$}if$}

FUNCTION{bbl.trans}{
  curlanguage "english" = 
              {check.auth.org empty$ compiler empty$ and {"Transl. "} {"transl. "} if$}
 {curlanguage "german"  = 
              {check.auth.org empty$ compiler empty$ and {"Übersetz. "} {"übersetz. "} if$}
 {curlanguage "ukrainian" = curlanguage "russian" = or
              {check.auth.org empty$ compiler empty$ and {"Пер. "} {"пер. "} if$}
 {"language is not defined: " curlanguage  " in bbl.trans" * * warning$ 
               check.auth.org empty$ compiler empty$ and {"Transl. "} {"transl. "}
 if$}if$}if$}if$
 origlanguage empty$ 'skip$ {origlanguage *} if$}

FUNCTION{bbl.edby}{
  curlanguage "english"   = {check.auth.org empty$ compiler empty$ and translator empty$ and
                               origlanguage empty$ and {"Ed.~by "} {"ed.~by "} if$}
 {curlanguage "german"    = {check.auth.org empty$ compiler empty$ and translator empty$ and
                               origlanguage empty$ and {"Ed.~"} {"ed.~"} if$}
 {curlanguage "ukrainian" = {check.auth.org empty$ compiler empty$ and translator empty$ and
                               origlanguage empty$ and {"За~ред. "} {"за~ред. "} if$}
 {curlanguage "russian"   = {check.auth.org empty$ compiler empty$ and translator empty$ and
                               origlanguage empty$ and {"Под ред. "} {"под ред. "} if$}
 {"language is not defined: " curlanguage " in bbl.edby" * * warning$ 
                             check.auth.org empty$ compiler empty$ translator empty$ and and 
                               origlanguage empty$ and {"Ed.~by "} {"ed.~by "}
 if$}if$}if$}if$}if$}

FUNCTION{bbl.ucedby}{
  curlanguage "english"   = {"Ed.~by "}
 {curlanguage "german"    = {"Ed.~"}
 {curlanguage "ukrainian" = {"За~ред. "}
 {curlanguage "russian"   = {"Под ред. "}
 {"language is not defined: " curlanguage " in bbl.ucedby" * * warning$ {"Ed.~by "}
 if$}if$}if$}if$}if$}

FUNCTION{format.compiler}  {compiler   empty$ {""} {bbl.compiler compiler format.names *} if$}
FUNCTION{format.editor}    {editor     empty$ {""} {bbl.edby editor       format.names *} if$}
FUNCTION{print.editor}     {editor     empty$ {""} {bbl.ucedby editor     format.names *} if$}
FUNCTION{format.translator}{
  translator empty$ 'bbl.trans {bbl.trans " " translator format.names * *} if$}

FUNCTION{comp.trans.edit}{
  author empty$ not type$ "book" = type$ "inbook" = or and {""}
    {compiler empty$ {"" 's :=} {format.compiler 's :=} if$
    translator empty$ 'skip$ 
      {s empty$ {format.translator 's :=} {s "~; " format.translator * * 's :=} if$}
    if$
    editor empty$ 'skip$ 
      {s empty$ {format.editor 's :=} {s "~; " format.editor * * 's :=} if$}
  if$ s}if$}

FUNCTION{address.or.location}{
  address empty$ {location empty$ {""} 'location if$} 'address if$}

FUNCTION{address.publisher}{
  publisher empty$ 'address.or.location 
    {address.or.location empty$ 'publisher {address.or.location ": " publisher * *} if$}
  if$}

FUNCTION{bbl.of}{
  curlanguage "english" = {" of "}
 {curlanguage "german"  = {" von "}
 {curlanguage "russian" = curlanguage "ukrainian" = or {"~; "}
 {"language is not defined: " curlanguage " in bbl.of" * * warning$ " of "}
  if$}if$}if$}

FUNCTION{volume.num.series}{
  volume empty$
    {number empty$ {""}
       {series empty$ not {series "~; " number * *}
          {"there's a number but no series in " cite$ * warning$ 
            bbl.No number thinspace.connect}
     if$}if$}
    {bbl.vol volume thinspace.connect
      series empty$ 'skip$ {bbl.of series * *} if$
      number empty$ 'skip$ {"can't use both volume and number fields in " * cite$ * warning$}
  if$}if$}

FUNCTION{format.title}{
  title empty$ {""}
    {title 's :=
     media      empty$ 'skip$ {s "~: " * media bracketise * 's :=} if$
     type$ "online" = type$ "patent" = or {s} {open.link s close.link * *} if$}
  if$}

FUNCTION{author.title}{
  author empty$ 'format.title
    {author num.names$ #4 < not 'format.title
       {format.authors emphasize
        title empty$ 'skip$ {add.period$ " " * format.title *} if$}
  if$}if$}

FUNCTION{book.creator}{
  author empty$ 'comp.trans.edit
    {author num.names$ #4 < 'comp.trans.edit 'format.authors if$}
  if$}

FUNCTION{check.book}{
  author empty$ editor empty$ compiler empty$ translator empty$ and and and
    {"empty author, compiler, editor and translator in " cite$ * warning$} 'skip$ if$
  check.title check.publisher check.year}

FUNCTION{book}{
  output.bibitem    check.book
  author.title      output new.slash
  book.creator      output new.block
  address.publisher output  
  format.date       output new.sentence
  volume.num.series output fin.entry}

FUNCTION{volume.series}{
  volume empty$ {""}
    {bbl.vol volume thinspace.connect
      series empty$ 'skip$ {bbl.of series * *} if$
      number empty$ 'skip$ {"can't use both volume and number fields in " * cite$ * warning$}
  if$}if$}

FUNCTION{series.number}{
  volume empty$ not {""}
    {series empty$ 
       {number empty$ {""} 
          {"there's a number but no series in " cite$ * warning$ 
            bbl.No number thinspace.connect} if$}
       {series "~; " *
        number empty$ 'skip$ {number *}
  if$}if$}if$}

FUNCTION{check.inbook}{
  pages empty$ chapter empty$ and not 'skip$
    {"empty pages and chapter in " cite$ * warning$} if$
  check.book}

FUNCTION{inbook}{
  output.bibitem    check.inbook
  author.title      output new.slash
  book.creator      output new.block
  address.publisher output  
  format.date       output new.sentence
  volume.series     output new.sentence
  format.pages      output new.sentence 
  series.number     output fin.entry}

FUNCTION{format.booktitle}{
  booktitle empty$ {""}
    {booktitle 's :=
     media      empty$ 'skip$ {s "~: " * media bracketise * 's :=} if$
     open.link s close.link * *}
  if$}

FUNCTION{check.incollection}{
  editor empty$ compiler empty$ translator empty$ and and not 'skip$
    {"empty compiler, editor and translator in " cite$ * warning$} if$
  check.booktitle check.author check.publisher check.year}

FUNCTION{incollection}{
  output.bibitem    check.incollection
  author.or.title   output new.dblslash
  format.booktitle  output new.slash
  comp.trans.edit   output new.block
  address.publisher output   
  format.date       output new.sentence
  volume.series     output new.sentence
  format.pages      output new.sentence 
  series.number     output fin.entry}

FUNCTION{creator}{
  publisher   empty$ not 'print.editor
 {org.inst.school empty$ 'format.editor
 {org.inst.school
  editor empty$ 'skip$ {"~; " format.editor * *}
  if$}if$}if$}

FUNCTION{check.proceedings}{check.title check.year} 

FUNCTION{proceedings}{
  output.bibitem    check.proceedings
  format.title      output new.slash
  creator           output new.block
  address.publisher output         
  format.date       output new.sentence
  volume.num.series output fin.entry}

FUNCTION{check.inproceedings}{check.proceedings check.booktitle check.author} 

FUNCTION{inproceedings}{
  output.bibitem    check.inproceedings
  author.or.title   output new.dblslash
  format.booktitle  output new.slash
  creator           output new.block
  address.publisher output   
  format.date       output new.sentence
  volume.series     output new.sentence
  format.pages      output new.sentence 
  series.number     output fin.entry}

FUNCTION{conference}{inproceedings}

FUNCTION{address.howpublished}{
  howpublished empty$ 'address.or.location 
    {address.or.location empty$ 'howpublished {address.or.location ": " howpublished * *} if$}
  if$}

FUNCTION{booklet.creator}{
  author empty$ 'creator
    {author num.names$ #4 < 'creator 'format.authors if$}
  if$}

FUNCTION{booklet}{
  output.bibitem       check.title
  author.title         output new.slash
  booklet.creator      output new.block
  address.howpublished output
  format.date          output fin.entry}

FUNCTION{author.title.org}{
  author.title empty$ 'org.inst.school
   {author.title
    org.inst.school empty$ 'skip$ {"~/ " org.inst.school * *} 
  if$}if$}

FUNCTION{format.edition}{edition empty$ {""} 'edition if$}

FUNCTION{manual}{
  output.bibitem      check.title
  author.title.org    output new.block
  address.or.location output
  format.date         output new.sentence
  format.edition      output fin.entry}

FUNCTION{eprintclass.or.primaryClass}{
  eprintclass empty$ {primaryClass empty$ {""} 'primaryClass if$} 'eprintclass if$}

FUNCTION{eprinttype.or.archivePrefix}{
  eprinttype empty$ {archivePrefix empty$ {""} 'archivePrefix if$} 'eprinttype if$}

FUNCTION{format.eprint}{
  eprint empty$ {""}
    {eprint 's :=
     eprintclass.or.primaryClass empty$ 'skip$ {eprintclass.or.primaryClass "\,/ " s * * 's :=} if$
     eprinttype.or.archivePrefix  empty$ 'skip$  {eprinttype  "\,: " s * * 's :=} if$
     eprinttype.or.archivePrefix "arXiv" = eprinttype.or.archivePrefix "arxiv" = or 
       {"\href{https://arxiv.org/abs/" eprint "}{" s "}" * * * *}
    {doi empty$ not {"\href{https://doi.org/" doi "}{" s "}" * * * *}
    {url empty$ 's  {"\href{" url "}{" s "}" * * * *}
  if$}if$}if$}if$}

FUNCTION{eprint.or.howpublished}{eprint empty$ 'howpublished 'format.eprint if$}

FUNCTION{check.misc}{
  author        empty$ title empty$ date empty$ and and 
  howpublished  empty$ year  empty$ note empty$ and and and
    {"all relevant fields are empty in " cite$ * warning$} 'skip$
  if$}

FUNCTION{misc}{
  output.bibitem         check.misc
  author.title           output new.block
  format.date            output new.sentence
  eprint.or.howpublished output new.sentence
  note                   output fin.entry}

FUNCTION{check.unpublished}{
  note empty$ {"empty note in " cite$ * warning$} 'skip$ if$
  check.author} 

FUNCTION{unpublished}{
  output.bibitem check.unpublished
  author.title   output new.block
  format.date    output new.sentence
  note           output fin.entry}

FUNCTION{bbl.urldate}{
  curlanguage "english"   = {"online; accessed "}
 {curlanguage "german"    = {"online; abgerufen "}
 {curlanguage "ukrainian" = {"дата звернення: "}
 {curlanguage "russian"   = {"дата обращения: "}
 {"language is not defined: " curlanguage " in bbl.urldate" * * warning$ "online; accessed "}
 if$}if$}if$}if$}

FUNCTION{doi.url}{
  doi empty$
    {url empty$ {""}
       {urldate empty$
          {"URL: \url{" url "}" * *}
          {"URL: \url{" url "} (" bbl.urldate urldate ")" * * * * *}
     if$}if$}
    {"DOI: \href{https://doi.org/" doi "}{" doi "}" * * * *}
  if$}

FUNCTION{doi.url.eprint}{
  doi empty$ url empty$ eprint empty$ and and {""}
    {doi empty$ url empty$ and 'format.eprint 'doi.url if$}
  if$}

FUNCTION{check.online}{
  doi empty$ url empty$ eprint empty$ and and not 'skip$ 
    {"empty doi, url and eprint in " cite$ * warning$}
  if$}

FUNCTION{online}{
  output.bibitem check.online
  author.title   output new.block
  doi.url.eprint output fin.entry}

FUNCTION{internet}  {online}
FUNCTION{www}       {online}
FUNCTION{webpage}   {online}
FUNCTION{electronic}{online}

FUNCTION{format.patent}{
  type            empty$  {"" 's :=}  {type 's :=} if$
  number          empty$ 'skip$ {s " " number * * 's :=} if$
  prioritycountry empty$ 'skip$ {s " " prioritycountry * * 's :=} if$
  open.link s close.link * *}

FUNCTION{check.patent}{
  number          empty$ {"empty number in "           cite$ * warning$} 'skip$ if$
  prioritycountry empty$ {"empty priority country in " cite$ * warning$} 'skip$ if$
  check.type}

FUNCTION{patent}{
  output.bibitem check.patent
  format.patent  output
  ipc            output new.sentence
  format.title   output fin.entry}

FUNCTION{bbl.techreport}{
  curlanguage "english"   = {"Rep. "}
 {curlanguage "german"    = {"Bericht "}
 {curlanguage "ukrainian" = {"Звіт "}
 {curlanguage "russian"   = {"Отчет "}
 {"language is not defined: " curlanguage " in bbl.techreport" * * warning$ "Rep. "}
 if$}if$}if$}if$}

FUNCTION{techreport.type}{type empty$ 'bbl.techreport 'type if$}

FUNCTION{bbl.executor}{
  curlanguage "english"   = {org.inst.school empty$ {"Exec. "} {"exec. "} if$}
 {curlanguage "german"    = {org.inst.school empty$ {"Exek. "} {"exek. "} if$}
 {curlanguage "ukrainian" = {org.inst.school empty$ {"Викон. "} {"викон. "} if$}
 {curlanguage "russian"   = {org.inst.school empty$ {"Исполн. "} {"исполн. "} if$}
 {"language is not defined: " curlanguage  " in bbl.executor" * * warning$ 
  org.inst.school empty$ {"Exec. "} {"exec. "}
 if$}if$}if$}if$}if$}

FUNCTION{format.executor}{author empty$ {""} {bbl.executor author format.names *} if$}

FUNCTION{institution.or.executor}{
  org.inst.school empty$ 'format.executor 'org.inst.school if$}

FUNCTION{check.report}{
  org.inst.school empty$ {"empty institution in " cite$ * warning$} 'skip$ if$
  check.type check.title check.year}

FUNCTION{report}{
  output.bibitem          check.report
  format.title            output new.sentence
  techreport.type         output add.blank
  number                  output new.slash
  institution.or.executor output new.block
  address.or.location     output
  format.date             output fin.entry}

FUNCTION{techreport}{report}

FUNCTION{check.thesis}{
  school empty$ publisher empty$ and
    {"empty school and publisher in " cite$ * warning$} 'skip$ if$
  check.author check.title check.type check.year}

FUNCTION{thesis}{
  output.bibitem    check.thesis
  format.authors emphasize output new.sentence
  format.title      output new.colon
  type              output new.slash
  org.inst.school   output new.block
  address.publisher output   
  format.date       output fin.entry}

FUNCTION{mastersthesis}{thesis}   
FUNCTION{phdthesis}    {thesis}
FUNCTION{docthesis}    {thesis}

FUNCTION{default.type}{misc}

READ

STRINGS{longest.label}
INTEGERS{number.label longest.label.width}
FUNCTION{initialize.longest.label}{
  "" 'longest.label :=
  #1 'number.label :=
  #0 'longest.label.width :=}

EXECUTE{initialize.longest.label}

FUNCTION{forward.pass}{
  number.label int.to.str$ 'label :=
  number.label #1 + 'number.label :=
  label width$ longest.label.width >
    {label 'longest.label :=
     label width$ 'longest.label.width :=}
    'skip$
  if$}

ITERATE{forward.pass}

FUNCTION{begin.bib}{
  "\begin{thebibliography}{"  longest.label  * "}" *            write$ newline$
  "\providecommand*{\href}[2]{{\small #2}}"                     write$ newline$
  "\providecommand*{\url}[1]{{\small #1}}"                      write$ newline$
  "\let\newblock\ignorespaces"                                  write$ newline$
  "\def\selectlanguageifdefined#1{%"                            write$ newline$
  "\expandafter\ifx\csname date#1\endcsname\relax"              write$ newline$
  "\else\selectlanguage{#1}\fi}"                                write$ newline$
  "\ProvideTextCommandDefault{\cyrdash}{%"                      write$ newline$
  "\iflanguage{russian}{\hbox to.8em{--\hss--}}{\textemdash}}"  write$ newline$
  "\providecommand*{\BibDash}{%"                                write$ newline$
  "\ifdim\lastskip>0pt\unskip\nobreak\hskip.2em plus 0.1em\fi%" write$ newline$
  "\cyrdash\hskip.2em plus 0.1em\ignorespaces}"                 write$ newline$
  preamble$ empty$ 'skip$ {preamble$ write$ newline$}  if$ }

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

EXECUTE{begin.bib}
EXECUTE{init.state.consts}
ITERATE{call.type$}
EXECUTE{end.bib}

%% End of file `gost.bst'.
