summaryrefslogtreecommitdiff
path: root/biblio/bibtex/utils/misc
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /biblio/bibtex/utils/misc
Initial commit
Diffstat (limited to 'biblio/bibtex/utils/misc')
-rw-r--r--biblio/bibtex/utils/misc/README5
-rw-r--r--biblio/bibtex/utils/misc/bbl2html.awk495
-rw-r--r--biblio/bibtex/utils/misc/bibfind38
-rw-r--r--biblio/bibtex/utils/misc/noTeX.bst1091
4 files changed, 1629 insertions, 0 deletions
diff --git a/biblio/bibtex/utils/misc/README b/biblio/bibtex/utils/misc/README
new file mode 100644
index 0000000000..3089769b82
--- /dev/null
+++ b/biblio/bibtex/utils/misc/README
@@ -0,0 +1,5 @@
+This directory contains single-file utilities that used to
+sit, alongside a bunch of directories, in biblio/bibtex/utils
+
+Robin Fairbairns
+For the CTAN Team
diff --git a/biblio/bibtex/utils/misc/bbl2html.awk b/biblio/bibtex/utils/misc/bbl2html.awk
new file mode 100644
index 0000000000..9c742053cb
--- /dev/null
+++ b/biblio/bibtex/utils/misc/bbl2html.awk
@@ -0,0 +1,495 @@
+#!/opt/local/bin/gawk -f
+#
+# bbl2html.awk v1.2c
+#
+# Released to the public domain (ie. use at your own risk)
+# Rik Blok <rikblok@mail.com>
+# December 13, 2000.
+#
+# Latest version available from
+# http://rikblok.cjb.net/scripts/bbl2html.awk
+#
+# Converts a LaTeX .bbl file to (mostly) formatted html code. Probably
+# also works if applied directly to a .tex file. Sets bookmarks
+# to the keys so you can reference a citation from another page, eg.
+# <a href="bib.html#key">[1]</a> will make a link to "key".
+#
+# bbl2html will use the default label unless you set (on the command-line)
+# override=key or override=number in which case it will use the citation
+# key or numeric format, respectively.
+#
+# I wrote this script out of dissatisfaction with other conversion tools
+# available. Hopefully it will be of use to somebody. Feel free to
+# modify the script to suit you. I've tested it with the bibliography
+# styles abbrv, alpha, apalike, ieeetr, plain, prsty, siam, and unsrt
+# and it works fairly well.
+# For a sample of the output visit http://rikblok.cjb.net/lib/refs.html.
+#
+# Usage:
+# awk -f bbl2html.awk head=<header> foot=<footer> \
+# [override = key|number] [labelwidth=<width>]
+# [bigtable = 0|1] [noabout=0|1] <infile> > <outfile>
+#
+# where
+# <header> and <footer> may be formatted text (enclosed in escaped
+# quotes if containing a space) to be placed at the beginning and end
+# of the output, respectively. As a special case, if either begins with
+# the symbol "@" it is assumed to be a filename and the text is read from
+# the file specified. If neither a header nor a footer is specified
+# <html><body> and </body></html> are used, respectively;
+# override is an optional variable to change the displayed label to
+# the citation key or numeric format;
+# <width> is the width of the column label, in pixels or, if appended
+# by "%", in percent (optional, defaults to 50 (pixels));
+# bigtable is an optional variable which allows the page to be
+# formatted as one big table (=1) or a separate table for each entry (=0)
+# (multiple tables can be displayed incrementally as the page loads but
+# a single table will be rendered faster. Optional, defaults to 0);
+# noabout is an optional variable which tells bbl2html.awk not to
+# print the "Generated by bbl2html.awk..." comment at the bottom of the
+# page (optional, defaults to 0);
+# <infile> is the name of the bibliography file (or LaTeX file?) to
+# be converted; and
+# <outfile> is the name of the html file to be generated.
+#
+# Sample usages:
+# awk -f bbl2html.awk head=\<html\>\<body\> foot=\</body\>\</html\> bib.bbl > bib.html
+# awk -f bbl2html.awk head=@bib.head foot=@bib.foot override=key bib.bbl > bib.html
+# awk -f bbl2html.awk -f myOwnSubstitutions.awk bib.bbl > bib.html
+# awk -f bbl2html.awk labelwidth=20% bigtable=1 bib.bbl > bib.html
+#
+# Notes:
+#
+# 1) You can add your own substitutions fairly easily by setting
+# userfind[] and userreplace[] in the BEGIN action. You can also
+# place the substitutions in a separate awk file (within a BEGIN
+# action) to avoid modifying this script (see the last example above
+# for a sample usage).
+#
+# 2) To generate a complete list of citations from a bibtex file
+# myreferences.bib use the bbl file generated by this latex file:
+#
+# %%%% begin latex file
+# \documentclass{article}
+# \usepackage{url} % if your citations have any \url{} commands
+# \begin{document}
+# \nocite{*}
+# \bibliographystyle{unsrt} % use whichever style you prefer
+# \bibliography{myreferences} % use myreferences.bib
+# \end{document}
+# %%%% end latex file
+#
+# 3) bbl2html.awk needs GNU awk/gawk. On Solaris machines, neither
+# /usr/bin/awk nor /usr/bin/nawk work.
+#
+# 4) If you download this file make sure it has the proper line-endings
+# for your filesystem. Otherwise running the script will probably
+# generate an "^ Invalid char" error. On Unix, process the script
+# with dos2unix if you encounter this error.
+#
+# 5) Any occurrences of "<" and ">" must be escaped in header
+# and footer. Eg. head=\<html\>\<body\> foot=\</body\>\<html\>
+# (not needed in files header/footer may point to).
+#
+# Revisions:
+# v1.2c December 13, 2000
+# - added Unix shell header (!/opt/local/bin/gawk -f) to run script
+# as a shell command. The path may need to be modified on your
+# machine.
+# - labelwidth now defaults to pixels. Append a percent symbol to
+# use as percent (eg. "labelwidth=20%").
+# - more linebreaks allowed in urls
+# - fixed: end-of-line comments ("%\n") left in txt of \href{url}{txt}
+# - adds "Generated by bbl2html.awk..." comment at bottom of file
+# (can be disabled with "noabout=1" command-line parameter)
+# v1.2b December 11, 2000
+# - fixed: chokes on \href{url}%\n{text}
+# - basic math support (italics, super- and sub-scripts)
+# - now has bookmarks (<a name="...">) for both keys and labels
+# (if different)
+# v1.2 December 7, 2000
+# - basic support for \href{url}{txt} (tries to guess how to format
+# 'txt', either as text or as an url)
+# - if neither header nor footer specified, defaults to
+# head="<html><body>" and foot="</body></html>"
+# v1.1 November 5, 2000
+# - added labelwidth option (percentage)
+# - rudimentary support for smallcaps
+# - added notes 4 and 5
+# v1.0c August 25, 2000
+# - replaced userfind[]/userreplace[] indices with descriptive keys
+# v1.0b July 31, 2000
+# - replaceFormat() checks for multiple occurrences of formatting
+# - now handles more general keys
+# - supports most bibliography styles (that I know of)
+# - defaults to using whatever labels are supplied, or numeric (if none)
+# - can override label with override=key or override=number
+# v1.0 July 28, 2000
+# - initial release
+#
+# To do:
+# - nothing urgent
+#
+# Thanks to:
+# - Marc Mutz for bug-hunting and the math substitutions
+#--------------------------------------------------------------------------
+BEGIN {
+ # bbl2html.awk information
+ version = "1.2c";
+ home = "http://rikblok.cjb.net/scripts/index.html#bbl2html.awk";
+
+ # put user-defined substitutions here
+ # arXiv.org preprint archive
+ userfind["arxiv"] = "arXiv:([a-zA-Z\.\-]+\/[0-9][0-9][0-9][0-9][0-9][0-9][0-9])";
+ userreplace["arxiv"] = "<a href=\"http://arXiv.org/abs/\\1\"><tt>arXiv:\\1</tt></a>";
+ # siam style uses a horizontal line in place of repeating author names
+ userfind["siam1"] = "\\\\leavevmode\\\\vrule height 2pt depth -1.6pt width 23pt";
+ userreplace["siam1"] = "<strike>\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;\\&nbsp;</strike>";
+ # some trivial math
+ userfind["math"] = "([^\\\\])\\$([^\\$]*)\\$";
+ userreplace["math"] = "\\1<var>\\2</var>";
+ # for super and subscripts:
+ userfind["math.sub"] = "([^\\\\])(\\$|<var>)(.*)_([a-zA-Z0-9]|{.*}|\\\\[a-zA-Z]+)([^\\$]*)(\\$|</var>)";
+ userreplace["math.sub"] = "\\1<var>\\3<sub>\\4</sub>\\5</var>";
+ userfind["math.sup"] = "([^\\\\])(\\$|<var>)(.*)\\^([a-zA-Z0-9]|{.*}|\\\\[a-zA-Z]+)([^\\$]*)(\\$|</var>)";
+ userreplace["math.sup"] = "\\1<var>\\3<sup>\\4</sup>\\5</var>";
+
+ # strip out everything before "\begin{thebibliography}"
+ while (line !~/\\begin{thebibliography}/)
+ getline line;
+
+ NR=0;
+
+ RS = "\\\\bibitem"; # record separator = "\bibitem"
+ FS = "\\\\newblock[ \n]+"; # field separator = "\newblock "
+}
+
+NR == 1 { # on begin, after reading command-line parameters
+ if (!head && !foot) { # if both undefined then use defaults
+ head = "<html><body>";
+ foot = "</body></html>";
+ }
+
+ # put in header
+ printhf(head);
+
+ # default labelwidth = 50 (pixels)
+ if (!labelwidth) labelwidth = 50;
+
+ if (bigtable) print "<table width=\"100%\">";
+}
+
+# every record
+{
+ label = ""; # erase label
+}
+
+# leading "[", set label and strip "[...]" from $1
+$1 ~ /^\[/ {
+ right = matchBrace($1,1);
+ label = substr($1,2,right-2);
+
+ # alpha style
+ sub(/{\\etalchar{\+}}/,"+",label); # replace "{\etalchar{+}}" --> "+"
+
+ # apalike style
+ label = authorFormat(label);
+
+ # strip label from line
+ $1 = substr($1,right+1);
+}
+
+# leading "{"
+$1 ~ /^{/ {
+ keycount++;
+ # if label not already set or override then set to number
+ if (!label || override=="number") label = keycount;
+
+ # get length of key from $1
+ right = matchBrace($1,1);
+
+ # set bookmark to key
+ key = substr($1,2,right-2);
+
+ # use key as label?
+ if (override=="key") label = key;
+
+ if (!bigtable) print "<table width=\"100%\">";
+ print "<tr><td width=\"" labelwidth "\" valign=\"top\">";
+ printf("<a name=\"" key "\">");
+ print "[" label "]";
+ if (key != label) printf("<a name=\"" label "\">");
+ printf("</td><td");
+ # fixing width=100% looks better when using multiple tables
+ if (!bigtable) printf(" width=\"100%\"");
+ printf(">");
+
+ # strip key out of first line
+ line = substr($1,right+1);
+
+ # process each line
+ lineno=1;
+ while (lineno<=NF) {
+ # if last line then check for "\end{thebibliography}"
+ if (lineno==NF) sub(/\n\\end{thebibliography}/,"",line);
+
+ # first take out any urls before any more processing
+ while ((left=match(line,/\\url{/))>0) {
+ right= matchBrace(line,RSTART+4);
+ if (right>left) {
+ urlcnt++;
+ url[urlcnt] = substr(line,left+5,right-left-5); # assumes just one url per line
+ line = substr(line,1,left-1) "__URL" urlcnt "__" substr(line,right+1);
+ }
+ }
+ # repeat for hrefs
+ while ((left=match(line,/\\href{/))>0) {
+ right= matchBrace(line,RSTART+5);
+ if (right>left) {
+ urlcnt++;
+ url[urlcnt] = substr(line,left+6,right-left-6); # assumes just one url per line
+ # now find href text, starting with next '{'
+ if ((left2 = match(substr(line,right+1),/{/))>0) {
+ left2 += right;
+ right = matchBrace(line,left2);
+ txt[urlcnt] = substr(line,left2+1,right-left2-1);
+ }
+ # replace
+ line = substr(line,1,left-1) "__URL" urlcnt "__" substr(line,right+1);
+ }
+ }
+
+ line = authorFormat(line);
+
+ # re-insert formatted urls
+ while (urlcnt) {
+ url[urlcnt] = urlFormat(url[urlcnt],txt[urlcnt]);
+ urlmark = "__URL" urlcnt "__";
+ # can't use sub() because url[urlcnt] may contain "&"
+ # sub(urlmark,url[urlcnt],line);
+ if (match(line,urlmark)) {
+ line = substr(line,1,RSTART-1) url[urlcnt] substr(line,RSTART+RLENGTH);
+ }
+ urlcnt--;
+ }
+ print line "<br>";
+
+ # get ready for next line
+ lineno++;
+ line = $lineno;
+ }
+
+ printf("</td></tr>");
+ if (!bigtable) print "</table>";
+}
+
+END {
+ if (bigtable) print "</table>";
+ if (!noabout) {
+ print "<hr><font size=\"-1\"><address>Generated by <a href=\"" home "\">bbl2html.awk</a> v" version "</address></font>";
+ }
+ if (foot) printhf(foot);
+}
+#--------------------------------------------------------------------------
+function authorFormat( s,
+ left,right)
+# substitute accents in author-type string s.
+{
+ # first replace small-caps formatting style so accents are handled properly
+ s = replaceFormatSC(s);
+
+ # next, replace accents
+ s = gensub(/\\'([AEIOUYaeiouy])/, "\\&\\1acute;", "g", s);
+ s = gensub(/\\`([AEIOUaeiou])/, "\\&\\1grave;", "g", s);
+ s = gensub(/\\\^([AEIOUaeiou])/, "\\&\\1circ;", "g", s);
+ s = gensub(/\\~([AEINOUaeinou])/, "\\&\\1tilde;", "g", s);
+ s = gensub(/\\[\.]([AEIOUaeiou])/, "\\&\\1ring;", "g", s);
+ s = gensub(/\\\"([AEIOUaeiou])/, "\\&\\1uml;", "g", s);
+ s = gensub(/\\([Oo])/, "\\&\\1slash;", "g", s);
+ s = gensub(/\\(AE|ae)/, "\\&\\1lig;", "g", s);
+ gsub(/\\ss/,"\\&szlig;",s); # German sharp s
+ gsub(/~/,"\\&nbsp;",s); # replace nonbreaking spaces: ~ --> &nbsp;
+ gsub(/\\[,@]/," ",s); # replace spaces
+ gsub(/``|''/,"\\&quot;",s); # replace quotes
+ gsub(/---/,"-",s); # replace dashes
+ gsub(/--/,"-",s);
+
+ # these accents can't be displayed in HTML (with my charset) so delete 'em
+ s = gensub(/\\[bcduvH]{([a-zA-Z])}/, "\\1", "g", s); # eg. \u{o}
+ gsub(/{\\AA}/,"A",s); # \AA --> A
+ gsub(/{\\aa}/,"a",s); # \aa --> a
+
+ # user-defined substitutions
+ for (i in userfind) {
+ s = gensub(userfind[i], userreplace[i], "g", s);
+ }
+
+ # replace formatting styles
+ s = replaceFormat(s,"\\em","<em>","</em>"); # replace emphasis
+ s = replaceFormat(s,"\\bf","<b>","</b>"); # replace bold
+ s = replaceFormat(s,"\\it","<i>","</i>"); # replace italics
+ s = replaceFormat(s,"\\tt","<tt>","</tt>"); # replace teletype
+
+ gsub(/{|}/,"",s); # drop any remaining braces
+ gsub(/\\/,"",s); # drop any remaining slashes
+ return s;
+}
+#--------------------------------------------------------------------------
+function urlFormat( url, # function parameters
+ display) # optional variables
+# Format a url. If 'display' is passed then try to determine if it should
+# be displayed formatted author-like or url-like.
+{
+# gsub(/\&/,"\\\\&",url); # escape "&"s (hmm, apparently I don't need this...)
+ gsub(/ /,"",url); # strip spaces
+ gsub(/%\n/,"",url); # strip end-of-line comments
+ gsub(/\n/,"",url); # strip other linebreaks
+ gsub(/%\n/,"",display); # also strip end-of-line comments in display
+
+
+ # guess how to format display, either as an url or authorFormat()
+ if (!display || tolower(display) ~ /:\/\/|^mailto:/) {
+ if (!display) display = url; # default display = formatted url
+ # allow linebreaks after punctuation symbols for display purposes
+ display = "<tt>" gensub(/([^A-Za-z0-9 ])/,"\\1<wbr>","g",display) "</tt>";
+ } else {
+ display = authorFormat(display);
+ }
+
+ return "<a href=\"" url "\">" display "</a>";
+}
+#--------------------------------------------------------------------------
+function printhf( s, # function parameters
+ line) # local variables
+# Prints s (head or foot). If s starts with "@" then is assumed to
+# be a filename and prints the contents of the file
+{
+ # if no leading "@" then just print s
+ if (s !~ /^@/) {
+ print s;
+ return;
+ }
+
+ # else print contents of file s
+ s = substr(s,2); # drop leading "@"
+ while ((getline line < s) > 0)
+ print line;
+ close(s);
+}
+#--------------------------------------------------------------------------
+function replaceFormat( s,find,replaceleft,replaceright, # function parameters
+ left, right) # local variables
+# Replace formatting style marks. Use to change things like {\it et al.}
+# into {<it> et al.</it>} with the usage
+# s = replaceFormat(s,"\\it","<i>","</i>");
+{
+ while ((left = index(s,find))>0) {
+ right = matchBrace(s,left,"{"); # find "}" which matches assumed "{" at position 'left'
+ if (right>left) {
+ s = substr(s,1,right-1) replaceright substr(s,right);
+ }
+ s = substr(s,1,left-1) replaceleft substr(s,left+length(find));
+ }
+ return s;
+}
+#--------------------------------------------------------------------------
+function replaceFormatSC( s, # function parameters
+ find,replaceleft,replaceright, # local variables
+ left, right,l,c,r,cout,i,capslock,ch)
+# Replace small caps "{\sc ...}" formatting style marks.
+# Should be called before accents are replaced (so that "\'a" --> "\'A",
+# for example, instead of "&aacute;" --> "&AACUTE;".)
+# This routine is not robust, it assumes only a small subset of LaTeX
+# commands (such as accents) will be found in the text s. Unanticipated
+# commands will probably be changed to uppercase (but, for now, this can
+# probably be corrected with userfind[]/userreplace[] substitutions).
+{
+ find = "\\sc";
+ replaceleft = "<font size=\"-1\">";
+ replaceright= "</font>";
+ while ((left = index(s,find))>0) {
+ right = matchBrace(s,left,"{"); # find "}" which matches assumed "{" at position 'left'
+ if (right<left) right = length(s);
+ # split s into parts
+ l = substr(s,1,left-1); # left
+ left += length(find);
+ c = substr(s,left,right-left+1)
+ r = substr(s,right+1);
+ # manipulate c
+ capslock=1; # start in uppercase
+ cout = "";
+ for (i=1; i<=length(c); i++) {
+ ch = substr(c,i,1);
+ if (ch ~ /[a-z]/) {
+ if (capslock) {
+ ch = replaceleft toupper(ch);
+ capslock = 0;
+ } else
+ ch = toupper(ch);
+ } else if (ch ~ /[A-Z0-9]/) {
+ if (!capslock) {
+ ch = replaceright ch;
+ capslock = 1;
+ }
+ }
+ cout = cout ch;
+ }
+ if (!capslock) cout = cout replaceright;
+ # correct mangled accents
+ gsub(/\\B{/, "\\b{", cout);
+ gsub(/\\C{/, "\\c{", cout);
+ gsub(/\\D{/, "\\d{", cout);
+ gsub(/\\U{/, "\\u{", cout);
+ gsub(/\\V{/, "\\v{", cout);
+
+ # recombine s
+ s = l cout r;
+ }
+ return s;
+}
+#@include matchBrace.awk
+#--------------------------------------------------------------------------
+# matchBrace.awk - library containing single function matchBrace()
+
+function matchBrace( s,i, # function parameters
+ open, # optional parameters
+ brace,depth,left,right,either,pos,start) # local variables
+# Finds the matching brace for the one at index i (or assume brace==open,
+# if specified) in string s. Returns
+# index of matching brace or zero if not found.
+{
+ # error trap
+ if (!i) return 0;
+
+ # if open not specified then read from substr(s,i,1)
+ if (!open) open = substr(s,i,1);
+
+ # identify type of braces and put in left and right
+ left = "([{<`)]}>'";
+ right= ")]}>'([{<`";
+ pos = index(left,open);
+ if (!pos) { # not in list of braces
+ left = open; # set left and right to the same thing
+ right= left;
+ either = "[" left "|" right "]"; # regexp (not escaped)
+ } else {
+ left = substr(left, pos,1); # found in list, set match
+ right= substr(right,pos,1);
+ either = "[\\" left "|\\" right "]"; # regexp (escaped)
+ }
+
+ # find matching brace
+ pos = i;
+ depth = 1;
+ while (depth) {
+ start += pos;
+ s = substr(s,pos+1);
+ if ((pos = match(s,either))>0) { # another brace found
+ if (substr(s,pos,1)==right) depth--;
+ else depth++;
+
+ } else return 0; # no more braces, return zero
+ }
+ return start+pos;
+}
+#--------------------------------------------------------------------------
diff --git a/biblio/bibtex/utils/misc/bibfind b/biblio/bibtex/utils/misc/bibfind
new file mode 100644
index 0000000000..f2ac1a3760
--- /dev/null
+++ b/biblio/bibtex/utils/misc/bibfind
@@ -0,0 +1,38 @@
+#!/usr/bin/perl
+#
+# bibfind -- Prints entries in your bib file that match search string.
+#
+# USAGE: bibfind <string> [<file>]
+#
+# Note:
+# Place bibfind in ~/bin, then chmod +x bibfind, then edit bibfind to change
+# the default bib file (see the variable $bibfile on line 29).
+#
+# 2001-07-05, Oyvind.Breivik@dnmi.no
+#
+
+### Arguments
+
+ my ($str,$file) = @ARGV;
+
+### Locals
+
+ my @paragraphs;
+ my $home;
+ my $bibfile;
+
+### Main
+
+ die "USAGE: $0 <string> [<file>]\n" if $#ARGV < 0;
+ $/ = ''; # $INPUT_RECORD_SEPARATOR set to read paragraphs
+ $home = $ENV{"HOME"};
+ $bibfile = "$home/dok/tex/bibtex/Breivik.bib"; # Default bibtex file
+ $file = $bibfile if ($#ARGV < 1);
+
+ open(FILE, $file) or die "ERROR: Can't open $file";
+ print "$file\n";
+ @paragraphs = <FILE>; # Slurp up file by paragraph
+
+ foreach (@paragraphs) {
+ print if /$str/i; # Case ignored, if wanted, remove trailing i.
+ }
diff --git a/biblio/bibtex/utils/misc/noTeX.bst b/biblio/bibtex/utils/misc/noTeX.bst
new file mode 100644
index 0000000000..4f2aa6649a
--- /dev/null
+++ b/biblio/bibtex/utils/misc/noTeX.bst
@@ -0,0 +1,1091 @@
+%
+%
+% BibTeX bibliography style `noTeX' 1.1 (2000/06/18)
+% by Sebastiano Vigna <vigna@acm.org> (starting from the plain.bst style)
+%
+% This stuff is Copyright (C) by the plain.bst author. My changes
+% are public domain.
+%
+% This style generates a number of HTML P elements of class noTeX,
+% one for each entry. The resulting .bbl file can be included in an
+% HTML document. The noTeX field is like the standard note field,
+% but it is only included here, while note is not looked at (so
+% you can have an HTML and a TeX version of the note field). The
+% noTeXtra field is HTML BODY material that is appended to the
+% result; it can contain, say, an abstract, references to ftp
+% sites and so on.
+%
+
+ENTRY
+ { address
+ author
+ booktitle
+ chapter
+ edition
+ editor
+ howpublished
+ institution
+ journal
+ key
+ month
+ number
+ organization
+ pages
+ publisher
+ school
+ series
+ title
+ type
+ volume
+ year
+ noTeX
+ noTeXtra
+ }
+ {}
+ { label }
+
+INTEGERS { output.state before.all mid.sentence after.sentence after.block }
+
+FUNCTION {init.state.consts}
+{ #0 'before.all :=
+ #1 'mid.sentence :=
+ #2 'after.sentence :=
+ #3 'after.block :=
+}
+
+STRINGS { s t }
+
+FUNCTION {output.nonnull}
+{ 's :=
+ output.state mid.sentence =
+ { ", " * write$ }
+ { output.state after.block =
+ { add.period$ write$
+ newline$
+ " " write$
+ }
+ { output.state before.all =
+ 'write$
+ { add.period$ " " * write$ }
+ if$
+ }
+ if$
+ mid.sentence 'output.state :=
+ }
+ if$
+ s
+}
+
+FUNCTION {output}
+{ duplicate$ empty$
+ 'pop$
+ 'output.nonnull
+ if$
+}
+
+FUNCTION {output.check}
+{ 't :=
+ duplicate$ empty$
+ { pop$ "empty " t * " in " * cite$ * warning$ }
+ 'output.nonnull
+ if$
+}
+
+FUNCTION {output.bibitem}
+{ "<P CLASS=noTeX>" write$
+ newline$
+ ""
+ before.all 'output.state :=
+}
+
+FUNCTION {fin.entry}
+{ add.period$
+ write$
+ newline$
+ noTeXtra empty$
+ { }
+ { noTeXtra write$ }
+ if$
+ 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 {not}
+{ { #0 }
+ { #1 }
+ if$
+}
+
+FUNCTION {and}
+{ 'skip$
+ { pop$ #0 }
+ if$
+}
+
+FUNCTION {or}
+{ { pop$ #1 }
+ 'skip$
+ if$
+}
+
+FUNCTION {new.block.checka}
+{ empty$
+ 'skip$
+ 'new.block
+ if$
+}
+
+FUNCTION {new.block.checkb}
+{ empty$
+ swap$ empty$
+ and
+ 'skip$
+ 'new.block
+ if$
+}
+
+FUNCTION {new.sentence.checka}
+{ empty$
+ 'skip$
+ 'new.sentence
+ if$
+}
+
+FUNCTION {new.sentence.checkb}
+{ empty$
+ swap$ empty$
+ and
+ 'skip$
+ 'new.sentence
+ if$
+}
+
+FUNCTION {field.or.null}
+{ duplicate$ empty$
+ { pop$ "" }
+ 'skip$
+ if$
+}
+
+FUNCTION {emphasize}
+{ duplicate$ empty$
+ { pop$ "" }
+ { "<EM>" swap$ * "</EM>" * }
+ 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 }
+ if$
+}
+
+FUNCTION {format.editors}
+{ editor empty$
+ { "" }
+ { editor format.names
+ editor num.names$ #1 >
+ { ", editors" * }
+ { ", editor" * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.title}
+{ title empty$
+ { "" }
+ { title "t" change.case$ }
+ if$
+}
+
+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$
+}
+
+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$
+}
+
+FUNCTION {format.bvolume}
+{ volume empty$
+ { "" }
+ { "volume" volume tie.or.space.connect
+ series empty$
+ 'skip$
+ { " of " * series emphasize * }
+ if$
+ "volume and number" number either.or.check
+ }
+ if$
+}
+
+FUNCTION {format.number.series}
+{ volume empty$
+ { number empty$
+ { series field.or.null }
+ { output.state mid.sentence =
+ { "number" }
+ { "Number" }
+ if$
+ number tie.or.space.connect
+ series empty$
+ { "there's a number but no series in " cite$ * warning$ }
+ { " in " * series * }
+ if$
+ }
+ if$
+ }
+ { "" }
+ if$
+}
+
+FUNCTION {format.edition}
+{ edition empty$
+ { "" }
+ { output.state mid.sentence =
+ { edition "l" change.case$ " edition" * }
+ { edition "t" change.case$ " edition" * }
+ if$
+ }
+ 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.pages}
+{ pages empty$
+ { "" }
+ { pages multi.page.check
+ { "pages" pages n.dashify tie.or.space.connect }
+ { "page" pages tie.or.space.connect }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.vol.num.pages}
+{ volume field.or.null
+ number empty$
+ 'skip$
+ { "(" number * ")" * *
+ volume empty$
+ { "there's a number but no volume in " cite$ * warning$ }
+ 'skip$
+ if$
+ }
+ if$
+ pages empty$
+ 'skip$
+ { duplicate$ empty$
+ { pop$ format.pages }
+ { ":" * pages n.dashify * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.chapter.pages}
+{ chapter empty$
+ 'format.pages
+ { type empty$
+ { "chapter" }
+ { type "l" change.case$ }
+ if$
+ chapter tie.or.space.connect
+ pages empty$
+ 'skip$
+ { ", " * format.pages * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.in.ed.booktitle}
+{ booktitle empty$
+ { "" }
+ { editor empty$
+ { "In " booktitle emphasize * }
+ { "In " format.editors * ", " * booktitle emphasize * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {empty.misc.check}
+{ author empty$ title empty$ howpublished empty$
+ month empty$ year empty$ noTeX empty$
+ and and and and and
+ key empty$ not and
+ { "all relevant fields are empty in " cite$ * warning$ }
+ 'skip$
+ if$
+}
+
+FUNCTION {format.thesis.type}
+{ type empty$
+ 'skip$
+ { pop$
+ type "t" change.case$
+ }
+ if$
+}
+
+FUNCTION {format.tr.number}
+{ type empty$
+ { "Technical Report" }
+ 'type
+ if$
+ number empty$
+ { "t" change.case$ }
+ { number tie.or.space.connect }
+ if$
+}
+
+FUNCTION {format.article.crossref}
+{ key empty$
+ { journal empty$
+ { "need key or journal for " cite$ * " to crossref " * crossref *
+ warning$
+ ""
+ }
+ { "In {\em " journal * "\/}" * }
+ if$
+ }
+ { "In " key * }
+ if$
+ " \cite{" * crossref * "}" *
+}
+
+FUNCTION {format.crossref.editor}
+{ editor #1 "{vv{ } }{ll{ }}" format.name$
+ editor num.names$ duplicate$
+ #2 >
+ { pop$ " et al." * }
+ { #2 <
+ 'skip$
+ { editor #2 "{ff{ } }{vv{ } }{ll{ }}{ jj{ }}" format.name$ "others" =
+ { " et al." * }
+ { " and " * editor #2 "{vv{ } }{ll{ }}" format.name$ * }
+ if$
+ }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.book.crossref}
+{ volume empty$
+ { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
+ "In "
+ }
+ { "Volume" volume tie.or.space.connect
+ " of " *
+ }
+ if$
+ editor empty$
+ editor field.or.null author field.or.null =
+ or
+ { key empty$
+ { series empty$
+ { "need editor, key, or series for " cite$ * " to crossref " *
+ crossref * warning$
+ "" *
+ }
+ { "{\em " * series * "\/}" * }
+ if$
+ }
+ { key * }
+ if$
+ }
+ { format.crossref.editor * }
+ if$
+ " \cite{" * crossref * "}" *
+}
+
+FUNCTION {format.incoll.inproc.crossref}
+{ editor empty$
+ editor field.or.null author field.or.null =
+ or
+ { key empty$
+ { booktitle empty$
+ { "need editor, key, or booktitle for " cite$ * " to crossref " *
+ crossref * warning$
+ ""
+ }
+ { "In {\em " booktitle * "\/}" * }
+ if$
+ }
+ { "In " key * }
+ if$
+ }
+ { "In " format.crossref.editor * }
+ if$
+ " \cite{" * crossref * "}" *
+}
+
+FUNCTION {article}
+{ output.bibitem
+ format.authors "author" output.check
+ new.block
+ format.title "title" output.check
+ new.block
+ crossref missing$
+ { journal emphasize "journal" output.check
+ format.vol.num.pages output
+ format.date "year" output.check
+ }
+ { format.article.crossref output.nonnull
+ format.pages output
+ }
+ if$
+ new.block
+ noTeX output
+ fin.entry
+}
+
+FUNCTION {book}
+{ output.bibitem
+ author empty$
+ { format.editors "author and editor" output.check }
+ { format.authors output.nonnull
+ crossref missing$
+ { "author and editor" editor either.or.check }
+ 'skip$
+ if$
+ }
+ if$
+ new.block
+ format.btitle "title" output.check
+ crossref missing$
+ { format.bvolume output
+ new.block
+ format.number.series output
+ new.sentence
+ publisher "publisher" output.check
+ address output
+ }
+ { new.block
+ format.book.crossref output.nonnull
+ }
+ if$
+ format.edition output
+ format.date "year" output.check
+ new.block
+ noTeX output
+ fin.entry
+}
+
+FUNCTION {booklet}
+{ output.bibitem
+ format.authors output
+ new.block
+ format.title "title" output.check
+ howpublished address new.block.checkb
+ howpublished output
+ address output
+ format.date output
+ new.block
+ noTeX output
+ fin.entry
+}
+
+FUNCTION {inbook}
+{ output.bibitem
+ author empty$
+ { format.editors "author and editor" output.check }
+ { format.authors output.nonnull
+ crossref missing$
+ { "author and editor" editor either.or.check }
+ 'skip$
+ if$
+ }
+ if$
+ new.block
+ format.btitle "title" output.check
+ crossref missing$
+ { format.bvolume output
+ format.chapter.pages "chapter and pages" output.check
+ new.block
+ format.number.series output
+ new.sentence
+ publisher "publisher" output.check
+ address output
+ }
+ { format.chapter.pages "chapter and pages" output.check
+ new.block
+ format.book.crossref output.nonnull
+ }
+ if$
+ format.edition output
+ format.date "year" output.check
+ new.block
+ noTeX output
+ fin.entry
+}
+
+FUNCTION {incollection}
+{ output.bibitem
+ format.authors "author" output.check
+ new.block
+ format.title "title" output.check
+ new.block
+ crossref missing$
+ { format.in.ed.booktitle "booktitle" output.check
+ format.bvolume output
+ format.number.series output
+ format.chapter.pages output
+ new.sentence
+ publisher "publisher" output.check
+ address output
+ format.edition output
+ format.date "year" output.check
+ }
+ { format.incoll.inproc.crossref output.nonnull
+ format.chapter.pages output
+ }
+ if$
+ new.block
+ noTeX output
+ fin.entry
+}
+
+FUNCTION {inproceedings}
+{ output.bibitem
+ format.authors "author" output.check
+ new.block
+ format.title "title" output.check
+ new.block
+ crossref missing$
+ { format.in.ed.booktitle "booktitle" output.check
+ format.bvolume output
+ format.number.series output
+ format.pages output
+ address empty$
+ { organization publisher new.sentence.checkb
+ organization output
+ publisher output
+ format.date "year" output.check
+ }
+ { address output.nonnull
+ format.date "year" output.check
+ new.sentence
+ organization output
+ publisher output
+ }
+ if$
+ }
+ { format.incoll.inproc.crossref output.nonnull
+ format.pages output
+ }
+ if$
+ new.block
+ noTeX output
+ fin.entry
+}
+
+FUNCTION {conference} { inproceedings }
+
+FUNCTION {manual}
+{ output.bibitem
+ author empty$
+ { organization empty$
+ 'skip$
+ { organization output.nonnull
+ address output
+ }
+ if$
+ }
+ { format.authors output.nonnull }
+ if$
+ new.block
+ format.btitle "title" output.check
+ author empty$
+ { organization empty$
+ { address new.block.checka
+ address output
+ }
+ 'skip$
+ if$
+ }
+ { organization address new.block.checkb
+ organization output
+ address output
+ }
+ if$
+ format.edition output
+ format.date output
+ new.block
+ noTeX output
+ fin.entry
+}
+
+FUNCTION {mastersthesis}
+{ output.bibitem
+ format.authors "author" output.check
+ new.block
+ format.title "title" output.check
+ new.block
+ "Master's thesis" format.thesis.type output.nonnull
+ school "school" output.check
+ address output
+ format.date "year" output.check
+ new.block
+ noTeX output
+ fin.entry
+}
+
+FUNCTION {misc}
+{ output.bibitem
+ format.authors output
+ title howpublished new.block.checkb
+ format.title output
+ howpublished new.block.checka
+ howpublished output
+ format.date output
+ new.block
+ noTeX output
+ fin.entry
+ empty.misc.check
+}
+
+FUNCTION {phdthesis}
+{ output.bibitem
+ format.authors "author" output.check
+ new.block
+ format.btitle "title" output.check
+ new.block
+ "PhD thesis" format.thesis.type output.nonnull
+ school "school" output.check
+ address output
+ format.date "year" output.check
+ new.block
+ noTeX output
+ fin.entry
+}
+
+FUNCTION {proceedings}
+{ output.bibitem
+ editor empty$
+ { organization output }
+ { format.editors output.nonnull }
+ if$
+ new.block
+ format.btitle "title" output.check
+ format.bvolume output
+ format.number.series output
+ address empty$
+ { editor empty$
+ { publisher new.sentence.checka }
+ { organization publisher new.sentence.checkb
+ organization output
+ }
+ if$
+ publisher output
+ format.date "year" output.check
+ }
+ { address output.nonnull
+ format.date "year" output.check
+ new.sentence
+ editor empty$
+ 'skip$
+ { organization output }
+ if$
+ publisher output
+ }
+ if$
+ new.block
+ noTeX output
+ fin.entry
+}
+
+FUNCTION {techreport}
+{ output.bibitem
+ format.authors "author" output.check
+ new.block
+ format.title "title" output.check
+ new.block
+ format.tr.number output.nonnull
+ institution "institution" output.check
+ address output
+ format.date "year" output.check
+ new.block
+ noTeX output
+ fin.entry
+}
+
+FUNCTION {unpublished}
+{ output.bibitem
+ format.authors "author" output.check
+ new.block
+ format.title "title" output.check
+ new.block
+ noTeX "note" output.check
+ format.date output.check
+ new.block
+ noTeX output
+ fin.entry
+}
+
+FUNCTION {default.type} { misc }
+
+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"}
+
+MACRO {acmcs} {"ACM Computing Surveys"}
+
+MACRO {acta} {"Acta Informatica"}
+
+MACRO {cacm} {"Communications of the ACM"}
+
+MACRO {ibmjrd} {"IBM Journal of Research and Development"}
+
+MACRO {ibmsj} {"IBM Systems Journal"}
+
+MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
+
+MACRO {ieeetc} {"IEEE Transactions on Computers"}
+
+MACRO {ieeetcad}
+ {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
+
+MACRO {ipl} {"Information Processing Letters"}
+
+MACRO {jacm} {"Journal of the ACM"}
+
+MACRO {jcss} {"Journal of Computer and System Sciences"}
+
+MACRO {scp} {"Science of Computer Programming"}
+
+MACRO {sicomp} {"SIAM Journal on Computing"}
+
+MACRO {tocs} {"ACM Transactions on Computer Systems"}
+
+MACRO {tods} {"ACM Transactions on Database Systems"}
+
+MACRO {tog} {"ACM Transactions on Graphics"}
+
+MACRO {toms} {"ACM Transactions on Mathematical Software"}
+
+MACRO {toois} {"ACM Transactions on Office Information Systems"}
+
+MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
+
+MACRO {tcs} {"Theoretical Computer Science"}
+
+READ
+
+FUNCTION {sortify}
+{ purify$
+ "l" change.case$
+}
+
+INTEGERS { len }
+
+FUNCTION {chop.word}
+{ 's :=
+ 'len :=
+ s #1 len substring$ =
+ { s len #1 + global.max$ substring$ }
+ 's
+ if$
+}
+
+FUNCTION {sort.format.names}
+{ 's :=
+ #1 'nameptr :=
+ ""
+ s num.names$ 'numnames :=
+ numnames 'namesleft :=
+ { namesleft #0 > }
+ { nameptr #1 >
+ { " " * }
+ 'skip$
+ if$
+ s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
+ nameptr numnames = t "others" = and
+ { "et al" * }
+ { t sortify * }
+ if$
+ nameptr #1 + 'nameptr :=
+ namesleft #1 - 'namesleft :=
+ }
+ while$
+}
+
+FUNCTION {sort.format.title}
+{ 't :=
+ "A " #2
+ "An " #3
+ "The " #4 t chop.word
+ chop.word
+ chop.word
+ sortify
+ #1 global.max$ substring$
+}
+
+FUNCTION {author.sort}
+{ author empty$
+ { key empty$
+ { "to sort, need author or key in " cite$ * warning$
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { author sort.format.names }
+ if$
+}
+
+FUNCTION {author.editor.sort}
+{ author empty$
+ { editor empty$
+ { key empty$
+ { "to sort, need author, editor, or key in " cite$ * warning$
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { editor sort.format.names }
+ if$
+ }
+ { author sort.format.names }
+ if$
+}
+
+FUNCTION {author.organization.sort}
+{ author empty$
+ { organization empty$
+ { key empty$
+ { "to sort, need author, organization, or key in " cite$ * warning$
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { "The " #4 organization chop.word sortify }
+ if$
+ }
+ { author sort.format.names }
+ if$
+}
+
+FUNCTION {editor.organization.sort}
+{ editor empty$
+ { organization empty$
+ { key empty$
+ { "to sort, need editor, organization, or key in " cite$ * warning$
+ ""
+ }
+ { key sortify }
+ if$
+ }
+ { "The " #4 organization chop.word sortify }
+ if$
+ }
+ { editor sort.format.names }
+ if$
+}
+
+FUNCTION {presort}
+{ type$ "book" =
+ type$ "inbook" =
+ or
+ 'author.editor.sort
+ { type$ "proceedings" =
+ 'editor.organization.sort
+ { type$ "manual" =
+ 'author.organization.sort
+ 'author.sort
+ if$
+ }
+ if$
+ }
+ if$
+ " "
+ *
+ year field.or.null sortify
+ *
+ " "
+ *
+ title field.or.null
+ sort.format.title
+ *
+ #1 entry.max$ substring$
+ 'sort.key$ :=
+}
+
+ITERATE {presort}
+
+STRINGS { longest.label }
+
+INTEGERS { number.label longest.label.width }
+
+FUNCTION {initialize.longest.label}
+{ "" 'longest.label :=
+ #1 'number.label :=
+ #0 'longest.label.width :=
+}
+
+FUNCTION {longest.label.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$
+}
+
+EXECUTE {initialize.longest.label}
+
+ITERATE {longest.label.pass}
+
+EXECUTE {init.state.consts}
+
+ITERATE {call.type$}