% 1995 (C) Jussi Rintanen, Helsinki University of Technology

ENTRY
  { address
    author
    institution
    month
    number
    pages
    title
    type
    year
    keywords
    abstract
    file
  }
  {}
  { label extra.label sort.label }

STRINGS { s t }

FUNCTION {explode}
{
  "" swap$
  { duplicate$ "" = { pop$ #0 } { #1 } if$ }
  { duplicate$ #1 #1 substring$ swap$ #2 #1000 substring$ }
  while$
}

STRINGS { ssr sss }

FUNCTION {substitute}
{
  'ssr :=
  'sss :=
  explode
  ""
  { swap$ duplicate$ "" = { #0 } { #1 } if$ }
  { duplicate$ sss = { pop$ ssr swap$ * } { swap$ * } if$ }
  while$
  pop$
}
FUNCTION {not}
{   { #0 }
    { #1 }
  if$
}

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

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

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

FUNCTION {emphasize}
{ duplicate$ empty$
    { pop$ "" }
    { "{\em " swap$ * "}" * }
  if$
}

INTEGERS { nameptr namesleft numnames }

FUNCTION {format.names}
{ 's :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }

    { s nameptr "{ff }{vv}{ll}{, jj}" format.name$ 't :=

      nameptr #1 >
	{ namesleft #1 >
	    { ", " * t * }
	    { numnames #2 >
		{ "," * }
		'skip$
	      if$
	      t "others" =
		{ " et~al." * }
		{ " and " * t * }
	      if$
	    }
	  if$
	}
	't
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
}

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

FUNCTION {format.keywords}
{ keywords empty$
    { "" }
    { keywords }
  if$
}

FUNCTION {format.abstract}
{ abstract empty$
    { "" }
    { abstract }
  if$
}

FUNCTION {format.file}
{ file empty$
    { "" }
    { file }
  if$
}

FUNCTION {format.title}
{ title empty$
    { "" }

    { title "t" change.case$ "}" "" substitute "{" "" substitute }

  if$
}

FUNCTION {format.date}
{ year empty$
    { month empty$
	{ "" }
	{ "there's a month but no year in " cite$ * warning$
	  month
	}
      if$
    }
    { month empty$
	'year
	{ month " " * year * }
      if$
    }
  if$
}

FUNCTION {format.btitle}
{ title emphasize
}

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$
}

INTEGERS { multiresult }

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.tr.number}
{ type empty$
    { "Technical Report" }
    'type
  if$
  number empty$
    { "t" change.case$ }
    { number tie.or.space.connect }
  if$
}

FUNCTION {techreport}
{ "%A " write$ format.authors write$
  newline$
  "%T " write$ format.title write$
  newline$
  "%R " write$ format.tr.number write$
  newline$
  "%I " write$ institution write$
  newline$
  "%C " write$ address write$
  newline$
  "%D " write$ format.date write$
  newline$
  "%K " write$ format.keywords write$ newline$
  "%X " write$ format.abstract write$ newline$
  "%X " write$ format.file write$ newline$
  newline$
}

FUNCTION {default.type} { techreport }

MACRO {jan} {"January"}

MACRO {feb} {"February"}

MACRO {mar} {"March"}

MACRO {apr} {"April"}

MACRO {may} {"May"}

MACRO {jun} {"June"}

MACRO {jul} {"July"}

MACRO {aug} {"August"}

MACRO {sep} {"September"}

MACRO {oct} {"October"}

MACRO {nov} {"November"}

MACRO {dec} {"December"}

READ

ITERATE {call.type$}
