summaryrefslogtreecommitdiff
path: root/biblio/bibtex/utils/findbib
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/findbib
Initial commit
Diffstat (limited to 'biblio/bibtex/utils/findbib')
-rw-r--r--biblio/bibtex/utils/findbib/README73
-rw-r--r--biblio/bibtex/utils/findbib/addbib281
-rw-r--r--biblio/bibtex/utils/findbib/documentation.pdfbin0 -> 47947 bytes
-rw-r--r--biblio/bibtex/utils/findbib/documentation.tex82
-rw-r--r--biblio/bibtex/utils/findbib/example.pdfbin0 -> 57041 bytes
-rw-r--r--biblio/bibtex/utils/findbib/example.tex26
-rw-r--r--biblio/bibtex/utils/findbib/findbib474
-rw-r--r--biblio/bibtex/utils/findbib/utphys.bst1066
8 files changed, 2002 insertions, 0 deletions
diff --git a/biblio/bibtex/utils/findbib/README b/biblio/bibtex/utils/findbib/README
new file mode 100644
index 0000000000..32a23b5e2c
--- /dev/null
+++ b/biblio/bibtex/utils/findbib/README
@@ -0,0 +1,73 @@
+The simple shell script, findbib, gets a latex source file and finds the needed bibtex
+records in the physics archive at WWW-SPIRES.SLAC.STANFORD.EDU.
+
+References must be in one of the following forms:
+
+ - A SPIRES key: eg. \cite{Witten:1996ep}
+ - A new arXiv number: eg. \cite{0704.0001}
+ - An old arXiv number: eg. \cite{hep-th/9703030} or \cite{9703030}.
+
+SPIRES has provided a unique "two letter label" attached to each paper following the
+Author:Year identification. For example, "ep" in Witten:1997ep. Of course, one has
+to look on SPIRES to know them. However, eprint numbers, like hep-th/yymmxxx,
+yymmxxx and yymm.xxxx, are also supported labels. This allows you to retrieve the
+full record from just the arxiv numbers.
+If no arxiv name is specified, the scripts will search hep-th by default. This behaviour
+can be changed by editing the script.
+
+The scripts use awk, sed, lynx, bibtex and sometimes latex to generate the aux file.
+(Note that this shell script runs only under *nix.)
+
+Further details inside the files.
+
+Let me know of suggestions, improvements at:
+billnaai[~at~]gmail{-dot-}com
+
+1) Useage
+
+findbib [-a] filename.tex
+
+If the option -a is selected, the script will only add new citations. The default be-
+haviour is to create a new bibliography with all the citations.
+
+
+2) Installation
+
+After you untar it:
+
+tar xzvf findbib.tar.gz,
+
+just put findbib on your path and render it executable:
+
+chmod u+x findbib
+
+You also need to install awk, sed, lynx and ofcourse latex.
+(There is also a file, example.tex, that you can test the script on).
+
+3) Acknowledgements
+
+This script is a modified version of the script originally by Fabrizio Nesti.
+
+From the original script by Fabrizio Nesti:
+And thanks to Hrvoje 'Harv' Galic at SPIRES for collaboration!
+
+
+----------------------------------
+#######################################################################
+#
+# Findbib is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation (version 2)
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#######################################################################
+
+
diff --git a/biblio/bibtex/utils/findbib/addbib b/biblio/bibtex/utils/findbib/addbib
new file mode 100644
index 0000000000..ae3603b85d
--- /dev/null
+++ b/biblio/bibtex/utils/findbib/addbib
@@ -0,0 +1,281 @@
+#!/bin/bash -f
+# ADDBIB 0.2, Aug, 2007 K. Goldstein
+VERSION=0.2
+#
+#######################################################################
+#
+# ADDBIB 0.1, Feb, 2007 K. Goldstein
+# (based on FINDBIB 2.0 by F. Nesti).
+#
+# Usage: findbib foo.tex
+#
+# The script searchs for new citations in a latex AUX file and adds them to
+# a bibtex database. If the latex file is called foo.tex it assumes the bibtex file is
+# called foo.bib
+#
+# Every \cite{...} of a reference in SPIRES-Bibtex standard form
+# (Author:YEARaa) or in the form of an arXiv reference
+# (arXive-name/yymmnnn OR yymmnnn OR yymm.nnnn)
+# is searched in WWW-SPIRES.SLAC.STANFORD.EDU and all the bibtex records
+# added the file foo.BIB
+#
+# The value of the variable ARXIV sets the default arxiv to search if the
+# cite is of the form \cite{yymmxxx}
+#
+# To change the default arxiv change the value below:
+ARXIV='hep-th/'
+#ARXIV='hep-ph/'
+#
+####################################################################
+#
+# The script uses awk, sed, lynx, bibtex and somes LaTeX. You will have to install
+# these to make sure it works.
+#
+####################################################################
+# How the scrip works:
+#
+#
+# Steps:
+#
+# Generate an AUX file with LaTeX,
+# searches the AUX file for labels,
+# compares them with the records in the file $1.bib
+# searches SPIRES for new records,
+# adds them in $1.bib
+# calls BibTeX on the file (!).
+#
+#######################################################################
+#
+# ADDBIB 0.2, May, 2007 K. Goldstein
+#
+# add suport for the new arxiv format yymm.xxxx
+#
+#######################################################################
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation (version 2)
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+########################################
+#
+# Useful functions
+
+ #######################
+ # randomly pick a mirror
+ ######################
+
+get_url() {
+#cycle through the mirrors randomly
+ MIRRORS=("http://www-library.desy.de" "http://www-spires.fnal.gov" "http://usparc.ihep.su" "http://www-spires.dur.ac.uk" "http://www.yukawa.kyoto-u.ac.jp" "http://www.slac.stanford.edu" "http://www.spires.lipi.go.id")
+ element_count=${#MIRRORS[@]}
+ let mirror=$RANDOM%$element_count
+ BASE=${MIRRORS[$mirror]}
+ echo Querying $BASE
+ #####################
+ eval "$1=$BASE"/spires/find/hep/www?""
+}
+
+get_labels() {
+# extract the labels from the .aux file
+echo "---------- EXTRACTING LABELS FROM $FILE: -------------"
+
+awk -F"}" '/\\citation\{/ {for(i=1;i<NF+1;i++) print $i}' $FILE | \
+awk '/\\citation\{/ {print substr($0,match($0,/\\citation\{/)+RLENGTH,length)}'\
+ - | sort -u | tee bib.labels_a
+
+echo "---------- EXTRACTING RECORDS FROM $BIB: -------------"
+
+
+awk -F"{" '/Article/ {print $2}' $BIB | sed -e's/,//g' | sort | tee bib.labels_b
+
+echo "---------- FINDING NEW LABELS: -------------"
+
+while read label_a
+do
+ if [[ ! `grep $label_a bib.labels_b` ]]
+ then
+ echo $label_a | tee -a bib.labels
+ fi
+done < bib.labels_a
+
+rm -f bib.labels_a bib.labels_b
+
+nothing_new=0
+
+if [[ ! -f bib.labels ]]
+then
+ nothing_new=1
+fi
+}
+
+########################################################
+
+# Process the input parameters
+
+if [ $1 ]
+then
+ if test -f $1
+ then
+ TEXF=${1%.tex}
+ latex $1
+ FILE=${1%.tex}.aux
+ BIB=${1%.tex}.bib
+ else
+ echo "No such file $1."
+ exit
+ fi
+else
+ echo "usage: findbib texfile.tex"
+ exit
+fi
+echo $TEXF $FILE $BIB
+
+# extract the labels from the .aux file
+
+get_labels
+
+if [ $nothing_new -eq 1 ]
+then
+ echo "No new citations"
+ exit
+else
+# start getting the records from spires
+
+ echo "---------- REQUESTING RECORDS FROM spires.slac.stanford.edu:"
+# echo "%%" >> $BIB
+# echo "%% NEW RECORDS FOR $FILE. GENERATED BY FINDBIB 2.1 ON" \
+# `date +"%x, AT %X."`>>$BIB
+# echo "%%" >> $BIB
+
+ while read label
+ do
+ echo "------------------------------------------------------------"
+ flag=0
+ echo "Searching for label:"
+ ###########################################
+ # is the record of the form Author:yyyyxx ?
+ ###########################################
+ if [[ $label = *:[0-9][0-9][0-9][0-9][a-z][a-z]* ]]
+ then
+ LABEL=`echo $label | sed -es=:=/=`
+ AUTHOR=${LABEL%/*}
+ DATE=`echo ${LABEL#*/} | sed -e's=[a-z]*$==' `
+ KEY=`echo ${LABEL#*/} | sed -e's=^....==' `
+ # add a space in two word names:
+ AUTHOR_SPACE=`echo $AUTHOR | sed -e 's/\([a-z]\)\([A-Z]\)/\1 \2/g' `
+ #AUTHOR_SPACE=`echo $AUTHOR | sed 's/\([a-z]\)\([A-Z]\)/\1 \2/g'`
+ SEARCH=A+$AUTHOR_SPACE+AND+DATE+$DATE
+ echo $AUTHOR_SPACE $DATE $KEY
+ ###########################################
+ # is the record of the form *-*:yymmxxx ?
+ ###########################################
+ elif [[ $label = *-*/[0-9][0-9][0-9][0-9][0-9][0-9][0-9] ]]
+ then
+ SEARCH="EPRINT $label"
+ echo $label
+ ###########################################
+ # is the record of the form yymmxxx ?
+ ###########################################
+ elif [[ $label = [0-9][0-9][0-9][0-9][0-9][0-9][0-9] ]]
+ then
+ SEARCH="EPRINT $ARXIV$label"
+ echo $label
+ ###########################################
+ # is the record of the new form yymm.xxxx ?
+ ###########################################
+ elif [[ $label = [0-9][0-9][0-9][0-9]\.[0-9][0-9][0-9][0-9] ]]
+ then
+ SEARCH="EPRINT $label"
+ echo $label
+ ###########################################
+ # is the record some other format ?
+ ###########################################
+ else
+ echo $label: PERSONAL LABEL
+ flag=1
+ fi
+
+ i=0; NN=0
+
+ # start a loop to search through the results
+
+ while test $flag = "0"
+ do
+
+ # download the webpage from spires:
+ get_url URL
+ #URL="http://www-spires.slac.stanford.edu/spires/find/hep/www?"
+ OPTIONS="rawcmd=$SEARCH&skip=$i&FORMAT=wwwbriefbibtex"
+ lynx -source "$URL$OPTIONS" | sed -e '/@Article{/ s/ //g' > out
+
+ # increment our search - there are 25 results/page
+ let i=i+25
+ # find out the number of hits for our search
+ if [[ $NN -eq 0 ]]
+ then
+ if [[ `grep Paper out` ]]
+ then
+ NN=`grep Paper out | sed -e 's/^.*of <b>\([0-9]*\).*/\1/' | sort -u`
+ fi
+ echo $NN "record(s) found"
+ fi
+ if [[ $NN -gt 25 ]]
+ then
+ echo "Searching-----> " $i
+ fi
+ # check to see if there are no results:
+ if [[ $NN -eq 0 ]]
+ then
+ flag=1
+ echo " PAPER NOT FOUND."
+ # check to see if the label we want is on the page:
+ elif [[ ! `grep $label out` = "" ]]
+ then
+ flag=1
+ echo "Found:"
+ if [[ $SEARCH = EPRINT* ]]
+ then
+ if [[ ! `grep "<!-- START RESULTS -->" out` = "" ]]
+ then
+ echo "@Article{$label," >> $BIB
+ awk '/@Article\{/,/^}/' out | awk '!/@Article/' - \
+ | tee -a $BIB \
+ | grep title | sed 's/ */ /g'
+ else
+ echo "PAPER NOT FOUND"
+ fi
+ else
+ awk /$label/,'/^}/' out \
+ | tee -a $BIB \
+ | grep title | sed 's/ */ /g'
+ fi
+ # check to see if there are papers left:
+ elif [[ $i -gt $NN ]]
+ then
+ flag=1
+ echo " PAPER NOT FOUND."
+ fi
+
+ done
+
+
+done < bib.labels
+
+# clean up
+rm -f bib.labels out
+
+echo "---------- DONE. RECORDS WRITTEN TO $BIB."
+echo "---------- NOW RUNNING BIBTEX:"
+
+bibtex $TEXF
+
+fi
diff --git a/biblio/bibtex/utils/findbib/documentation.pdf b/biblio/bibtex/utils/findbib/documentation.pdf
new file mode 100644
index 0000000000..5b20117c41
--- /dev/null
+++ b/biblio/bibtex/utils/findbib/documentation.pdf
Binary files differ
diff --git a/biblio/bibtex/utils/findbib/documentation.tex b/biblio/bibtex/utils/findbib/documentation.tex
new file mode 100644
index 0000000000..8eee9ac6dc
--- /dev/null
+++ b/biblio/bibtex/utils/findbib/documentation.tex
@@ -0,0 +1,82 @@
+\documentclass{article}
+\usepackage{times}
+\usepackage[T1]{fontenc}
+\usepackage[latin1]{inputenc}
+\setlength\parskip{\medskipamount}
+\setlength\parindent{0pt}
+\usepackage{color}
+\usepackage{hyperref}
+\newcommand{\findbib}{\texttt{findbib} }
+
+
+\makeatletter
+
+\begin{document}
+\author{Kevin Goldstein}
+\title{Findbib documentation\date{}}
+
+\maketitle
+
+The simple shell script, \texttt{findbib}, gets a latex source file and finds the needed
+bibtex records in the physics archive at
+WWW-SPIRES.SLAC.STANFORD.EDU.\footnote{
+ \textcolor{red}{Note that this shell script runs only under *nix}.}
+
+References must be in one of the following forms:
+\begin{itemize}
+\item A SPIRES key: eg. \textbackslash{}cite\{Witten:1997ep\}
+\item A new arXiv number: eg. \textbackslash{}cite\{0704.0001\}
+\item An old arXiv number: eg. \textbackslash{}cite\{hep-th/9703030\}
+ or \textbackslash{}cite\{9703030\}.
+\end{itemize}
+
+SPIRES has provided a unique ``two letter label'' attached to each paper following the
+Author:Year identification. For example, ``ep'' in Witten:1997ep. Of course, one has to
+look on SPIRES to know them. However, eprint numbers, like hep-th/yymmxxx, yymmxxx and
+yymm.xxxx, are also supported labels. This allows you to retrieve the full
+record from just the arxiv numbers.
+
+If no arxiv name is specified, the scripts will search
+hep-th by default. This behaviour can be changed by editing the script.
+
+
+The scripts use awk, sed, lynx, bibtex and sometimes
+\LaTeX~to generate the \texttt{.aux} file. Further details inside the files.
+
+Let me know of suggestions, improvements at:
+
+\texttt{billnaai{[}\textasciitilde{}at\textasciitilde{}]gmail\{-dot-\}com}
+
+\section{Useage}
+
+\texttt{findbib [-a] filename.tex }
+
+If the option \texttt{-a} is selected, the script will only add new citations. The default
+behaviour is to create a new bibliography. By default the bibliography is called \texttt{filename.bib}.
+
+\section{Installation}
+
+After you untar it:
+
+ \texttt{tar xzvf findbib.tar.gz},
+
+just put \findbib on your path and render it executable:
+
+\texttt{chmod u+x findbib}
+
+You also need to install awk, sed, lynx and ofcourse latex.
+
+(There is also a file, example.tex, that you can
+test the script on).
+
+\section{Acknowledgements}
+
+This script is a modified version of the script originally
+by Fabrizio Nesti.
+
+--------
+
+From the original script by Fabrizio Nesti:
+
+And thanks to Hrvoje `Harv' Galic at SPIRES for collaboration!
+\end{document}
diff --git a/biblio/bibtex/utils/findbib/example.pdf b/biblio/bibtex/utils/findbib/example.pdf
new file mode 100644
index 0000000000..e81bb3e24f
--- /dev/null
+++ b/biblio/bibtex/utils/findbib/example.pdf
Binary files differ
diff --git a/biblio/bibtex/utils/findbib/example.tex b/biblio/bibtex/utils/findbib/example.tex
new file mode 100644
index 0000000000..0b269f4735
--- /dev/null
+++ b/biblio/bibtex/utils/findbib/example.tex
@@ -0,0 +1,26 @@
+\documentclass{article}
+\usepackage{showkeys}
+\usepackage{setspace}
+\doublespacing
+
+\begin{document}
+Here is an article \cite{Witten:1997ep}, and here
+another \cite{Li:1996mi}. Then a wrong author: \cite{Nobody:1997aa}
+and a wrong label \cite{Cheng:1996hh} with `hh' instead of `hc'.
+Then an eprint \cite{hep-th/9703030} and a personal label
+\cite{DNS:94} plus a commented out one. % \cite{pippo}.
+Then a label with an author whose last name has two words \cite{deWit:1984px}.
+Then label with no arxiv specified which will search the default arxiv \cite{0101001}.
+Finally, here is an article with the new arxiv numbering \cite{0704.0001}.
+
+Notice this file uses {\sf utphys.bst} as a bibliography style.
+Any other style may be used.
+
+This file also uses the package {\sf showkeys} to show the names of the citation keys.
+
+\bibliographystyle{utphys}
+\bibliography{example}
+
+\end{document}
+
+
diff --git a/biblio/bibtex/utils/findbib/findbib b/biblio/bibtex/utils/findbib/findbib
new file mode 100644
index 0000000000..b4332a0ed7
--- /dev/null
+++ b/biblio/bibtex/utils/findbib/findbib
@@ -0,0 +1,474 @@
+#!/bin/bash -f
+#FINDBIB 2.3, Aug, 2007 K. Goldstein
+#
+################ FINDBIB 2.0, F. Nesti, August, 26, 1997 ###############
+#
+# This script builds a bibliography database from the latex source file.
+#
+# Usage: findbib foo.tex
+#
+# Every \cite{...} of a reference in SPIRES-Bibtex standard form
+# (Author:YEARaa) or in the form of an arXiv reference
+# (arXive-name/yymmnnn OR yymmnnn OR yymm.nnnn)
+# is searched in WWW-SPIRES.SLAC.STANFORD.EDU and all the bibtex records
+# are returned in a .BIB file.
+#
+# The value of the variable ARXIV sets the default arxiv to search if the
+# cite is of the form \cite{yymmxxx}
+#
+# To change the default arxiv change the value below:
+#
+ARXIV='hep-th/'
+#ARXIV='hep-ph/'
+#
+# The .BIB file will have the same name as the .TEX file
+#
+# The script uses awk, sed, lynx, bibtex and somes LaTeX. You will have to install
+# these to make sure it works.
+#
+####################################################################
+#
+# How the script works:
+#
+# Steps:
+# Generate an AUX file with LaTeX if not present,
+# searches the AUX file for labels,
+# searches SPIRES for records,
+# writes them in $1.bib, renaming last as $1.bib.old,
+# calls BibTeX on the file (!).
+#
+#
+#
+#
+#######################################################################
+#
+# FINDBIB 2.1, May, 2007 K. Goldstein
+#
+# Changes:
+#
+# 1. Script updated to fix some changes on Spires website
+#
+# 2. Uses sort to remove dupilcate entries
+#
+# 3. Can search for author with double barrel surnames
+#
+# 4. every cite of the form \cite{yymmxxx} returns a hep-th reference.
+# To change the default arxiv the value of ARXIV
+#
+# 5. every cite of the form \cite{yymm.xxxx} returns a new arxiv reference
+#
+# 6. Gratuitous comments added so that the script is easy to fix
+# when spires changes their format
+#
+#######################################################################
+# FINDBIB 2.2 : fixed some bugs
+#######################################################################
+#######################################################################
+# FINDBIB 2.3 : added some flags
+#######################################################################
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation (version 2)
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+########################################
+
+# The main script starts around line 351
+# Useful functions defined:
+
+# Print usage infromation
+usage(){
+ echo "findbib $VERSION"
+ echo "---"
+ echo "Usage: findbib [-ah] texfile.tex"
+ echo
+ echo "Options:"
+ echo
+ echo " -a : Only add new citations"
+ echo " -h : Print this message"
+}
+
+#a counter
+cpp(){
+ c=$(($c+1))
+}
+
+# extract the labels from the .aux file
+get_labels() {
+###################
+# $1 - the .bib file
+# $2 - the .aux file
+# $3 - flag to see whether we should just get new labels
+###################
+ if [[ $3 = 0 ]]
+ then
+ get_all_labels $1 $2
+ else
+ get_new_labels $1 $2
+ fi
+}
+
+# function to process the labels
+parse_aux() {
+ echo "---------- EXTRACTING LABELS FROM $1: -------------"
+
+ awk -F"}" '/\\citation\{/ {for(i=1;i<NF+1;i++) print $i}' $1 | \
+ awk '/\\citation\{/ {print substr($0,match($0,/\\citation\{/)+RLENGTH,length)}'\
+ - | awk -F"," '{for (i=1; i<NF+1;i++) print $i}'| sort -u | tee $2
+
+}
+
+
+# extract all the labels from the .aux file
+get_all_labels() {
+####################
+# $1 = the .bib file
+# $2 = the .aux file
+#########################################
+ # Backup old bibtex file
+ if test -f $1
+ then
+ mv -f $1 $1.old
+ fi
+ out=bib.labels
+ parse_aux $2 $out
+}
+
+# extract new labels from the .aux file
+get_new_labels() {
+######################
+# $1 the .bib file
+# $2 the .aux file
+#########################################
+ # remove old files
+ if test -f bib.labels
+ then
+ rm -f bib.labels
+ fi
+
+ out=bib.labels_a
+ parse_aux $2 $out
+
+ echo "---------- EXTRACTING RECORDS FROM $1: -------------"
+
+
+ awk -F"{" '/[aA]rticle/ {print $2}' $1 | sed -e's/,//g' | sort | tee bib.labels_b
+
+ echo "---------- FINDING NEW LABELS: -------------"
+
+ while read label_a
+ do
+ if [[ ! `grep $label_a bib.labels_b` ]]
+ then
+ echo $label_a | tee -a bib.labels
+ fi
+ done < bib.labels_a
+
+ #clean up
+ rm -f bib.labels_a bib.labels_b
+
+ nothing_new=0
+
+ if [[ ! -f bib.labels ]]
+ then
+ nothing_new=1
+ fi
+}
+
+# add a comment to the bibtex file
+print_header() {
+######################
+# $1 - the .bib file
+# $2 - flag to see whether we should just get new labels
+######################
+ if [[ $2 = 0 ]]
+ then
+ echo "%%" > $1
+ echo "%% BIBTEX FILE FOR $TEXF.tex GENERATED BY FINDBIB $VERSION ON" \
+ `date +"%x, AT %X."`>>$1
+ echo "%%" >> $1
+ else
+ echo "%%" >> $1
+ echo "%% REFERENCES FOR $TEXF.tex ADDED BY FINDBIB $VERSION ON" \
+ `date +"%x, AT %X."`>>$1
+ echo "%%" >> $1
+ fi
+}
+
+
+parse_label() {
+# convert the label into a search term
+#$1 - a label extracted from the .aux file
+ ###########################################
+ # is the record of the form Author:yyyyxx ?
+ ###########################################
+ if [[ $1 = *:[0-9][0-9][0-9][0-9][a-z][a-z]* ]]
+ then
+ LABEL=`echo $1 | sed -es=:=/=`
+ AUTHOR=${LABEL%/*}
+ DATE=`echo ${LABEL#*/} | sed -e's=[a-z]*$==' `
+ KEY=`echo ${LABEL#*/} | sed -e's=^....==' `
+ # add a space in two word names and remove underscores:
+ AUTHOR_SPACE=`echo $AUTHOR | sed -e 's/\([a-z]\)\([A-Z]\)/\1 \2/g' `
+ SEARCH=A+$AUTHOR_SPACE+AND+DATE+$DATE
+ echo $AUTHOR_SPACE $DATE $KEY
+
+ ###########################################
+ # is the record of the form *-*:yymmxxx ?
+ ###########################################
+ elif [[ $1 = *-*/[0-9][0-9][0-9][0-9][0-9][0-9][0-9] ]]
+ then
+ SEARCH="EPRINT $1"
+ echo $1
+ ###########################################
+ # is the record of the form yymmxxx ?
+ ###########################################
+ elif [[ $1 = [0-9][0-9][0-9][0-9][0-9][0-9][0-9] ]]
+ then
+ SEARCH="EPRINT $ARXIV$1"
+ echo $1
+ ###########################################
+ # is the record of the new form yymm.xxxx ?
+ ###########################################
+ elif [[ $1 = [0-9][0-9][0-9][0-9]\.[0-9][0-9][0-9][0-9] ]]
+ then
+ SEARCH="EPRINT $1"
+ echo $1
+ ###########################################
+ ###########################################
+ # is the record some other format ?
+ ###########################################
+ else
+ echo $1: PERSONAL LABEL
+ flag=1
+ fi
+}
+
+get_url() {
+#######################
+# randomly pick a mirror
+######################
+ MIRRORS=("http://www-library.desy.de" "http://www-spires.fnal.gov" "http://usparc.ihep.su" "http://www-spires.dur.ac.uk" "http://www.yukawa.kyoto-u.ac.jp" "http://www.slac.stanford.edu")
+ element_count=${#MIRRORS[@]}
+ let mirror=$RANDOM%$element_count
+ BASE=${MIRRORS[$mirror]}
+ echo Querying $BASE
+ #####################
+ eval "$1=$BASE"/spires/find/hep/www?""
+}
+
+
+download_search (){
+#####################
+# Download a webpage with the search term $1
+# starting at result $2
+#####################
+ # get a random mirror:
+ get_url URL
+ OPTIONS="rawcmd=$1&skip=$2&FORMAT=wwwbriefbibtex"
+ # download page:
+ lynx -useragent=$USER_AGENT -source "$URL$OPTIONS" | sed -e '/@Article{/ s/ //g' >out
+ # sleep for 0-2 seconds between searches so we don't stress the servers
+ sleep $(($RANDOM%3))
+}
+
+get_hits (){
+#$1 is a string that will be set to the number of hits
+ #echo $SEARCH
+ if [[ `grep Paper out` ]]
+ then
+ export $1=`grep Paper out | sed -e 's/^.*of <b>\([0-9]*\).*/\1/' | sort -u`
+ #echo $1
+ fi
+}
+
+find_eprint_record(){
+ if [[ ! `grep "<!-- START RESULTS -->" out` = "" ]]
+ then
+ echo "@Article{$label," >> $BIB
+ awk '/@Article\{/,/^}/' out | awk '!/@Article/' - \
+ | tee -a $BIB \
+ | grep title | sed 's/ */ /g'
+ else
+ echo "PAPER NOT FOUND"
+ fi
+}
+find_record(){
+ awk /$label/,'/^}/' out \
+ | tee -a $BIB \
+ | grep title | sed 's/ */ /g'
+}
+process_filename() {
+ if [ $1 ]
+ then
+ if test -f ${1%.tex}.aux
+ then
+ TEXF=${1%.tex}
+ FILE=${1%.tex}.aux
+ BIB=${1%.tex}.bib
+ elif test -f $1
+ then
+ TEXF=${1%.tex}
+ latex $1
+ FILE=${1%.tex}.aux
+ BIB=${1%.tex}.bib
+ else
+ echo "No such file $1."
+ exit
+ fi
+ else
+ usage
+ exit
+ fi
+}
+
+test_dependancy () {
+
+test_dep=`whereis $1 | awk -F: '{print $2}'`
+
+if [ -z "$test_dep" ]
+ then
+ return 0
+ else
+ return 1
+fi
+
+}
+
+########################################################
+
+# test dependencies
+DEPS=("lynx" "sed" "awk")
+
+for item in ${DEPS[@]}
+do
+ test_dependancy $item
+ if [ $? = "0" ]
+ then
+ echo Findbib needs $item to work. Please install $item
+ exit
+ fi
+done
+
+#Boundary conditions
+VERSION=2.3
+c=0
+ADD=0
+LYNX_VERSION=`lynx -version | head -1 | awk '{print $3}'`
+USER_AGENT="Findbib_"$VERSION"_(Lynx/$LYNX_VERSION)"
+
+
+# Process the input parameters
+
+# Process flags:
+
+while getopts "b:ah" options
+do
+ case $options in
+ b ) BIBFILE=$OPTARG
+ # Unimplemented
+ cpp;cpp;;
+ a ) ADD=1
+ cpp;;
+ h ) usage
+ exit 1;;
+ \? ) usage
+ exit 1;;
+ * ) usage
+ exit 1;;
+ esac
+done
+
+shift $c
+
+# Process the name of the texfile
+
+process_filename $1
+
+# get citations from .aux file
+
+get_labels $BIB $FILE $ADD
+
+
+# print a header to the bibtex file
+
+print_header $BIB $ADD
+
+# start getting the records from spires
+
+echo "---------- REQUESTING RECORDS FROM spires.slac.stanford.edu:"
+
+while read label
+do
+ echo "------------------------------------------------------------"
+ flag=0
+ echo "Searching for label:"
+ i=0; NN=0
+
+ # parse the label and set $SEARCH to the SPIRES search term
+ parse_label $label
+
+ # start a loop to search through the results
+
+ while test $flag = "0"
+ do
+
+ download_search "$SEARCH" $i
+
+ let i=i+25
+ # find out the number of hits for our search
+ if [[ $NN -eq 0 ]]
+ then
+ get_hits NN
+ echo $NN "record(s) found "
+ fi
+ if [[ $NN -gt 25 ]]
+ then
+ echo "Searching-----> " $i
+ fi
+ # check to see if there were results
+ if [[ $NN -eq 0 ]]
+ then
+ flag=1
+ echo "PAPER NOT FOUND."
+ elif [[ ! `grep $label out` = "" ]]
+ then
+ flag=1
+ echo "Found:"
+ if [[ $SEARCH = EPRINT* ]]
+ then
+ find_eprint_record
+ else
+ find_record
+ fi
+ # check to see if there are no results:
+ # check to see if there are papers left:
+ elif [[ $i -gt $NN ]]
+ then
+ flag=1
+ echo " PAPER NOT FOUND."
+ fi
+ done
+
+
+done < bib.labels
+
+# clean up
+rm -f bib.labels out
+
+echo "---------- DONE. RECORDS WRITTEN TO $BIB."
+echo "---------- NOW RUNNING BIBTEX:"
+
+bibtex $TEXF
+
+exit
+
diff --git a/biblio/bibtex/utils/findbib/utphys.bst b/biblio/bibtex/utils/findbib/utphys.bst
new file mode 100644
index 0000000000..969f57abf7
--- /dev/null
+++ b/biblio/bibtex/utils/findbib/utphys.bst
@@ -0,0 +1,1066 @@
+% UT Physics bibliographic style, ver. 1.2. Based on:
+%
+%X IEEE Transactions bibliography style (29-Jan-88 version)
+%X numeric labels, order-of-reference, IEEE abbreviations,
+%X quotes around article titles, commas separate all fields
+%X except after book titles and before "notes". Otherwise,
+%X much like the "plain" family, from which this is adapted.
+%X
+%X History
+%X 9/30/85 (HWT) Original version, by Howard Trickey.
+%X 1/29/88 (OP&HWT) Updated for BibTeX version 0.99a, Oren Patashnik;
+%X THIS `ieeetr' VERSION DOES NOT WORK WITH BIBTEX 0.98i.
+%
+% Modifications: 1) added hypertex support and "archive" and "eprint" fields.
+% 2) parentheses around dates, and no "pp." for article entries
+% 3) "publisher, address" instead of "address: publisher"
+% 4) added "report" field for article entries.
+% 5) particle physics-oriented abbreviations, rather than ieee.
+% 6) added "collaboration" field, as per
+% Jonathan Flynn' suggestion. SPIRES now supports this field.
+%
+% Modified by Jacques Distler, 7/97
+% History: ver 1.0 9/96
+% ver 1.1 10/96 - added "collaboration" field
+% ver 1.2 7/97 - added a "\providecommand{\href}[2]{#2}"
+% to handle case where \href is not defined
+%
+% HyperTeX Wizardry:
+%
+% The following are equivalent:
+% archive = "hep-th"
+% eprint = "9605023"
+% and
+% eprint = "hep-th/9605023"
+% both produce
+% \href{http://xxx.lanl.gov/abs/hep-th/9605023}{{\tt hep-th/9605023}}
+% in the bibliographic output at the appropriate point. If you are using a
+% hypertex macropackage, like hyperref.sty, this will create a link to Los
+% Alamos.
+%
+% The bibtex output produced by SPIRES, while far from perfect, is pretty
+% suitable for use with this style. Indeed, this style was designed with
+% SPIRES in mind.
+
+ENTRY
+ { address
+ author
+ booktitle
+ chapter
+ edition
+ editor
+ howpublished
+ institution
+ journal
+ key
+ month
+ note
+ number
+ organization
+ pages
+ publisher
+ school
+ series
+ title
+ type
+ volume
+ year
+ archive
+ eprint
+ report
+ collaboration
+ }
+ {}
+ { label }
+
+INTEGERS { output.state before.all mid.sentence after.quote after.sentence
+ after.quoted.block after.block }
+
+FUNCTION {init.state.consts}
+{ #0 'before.all :=
+ #1 'mid.sentence :=
+ #2 'after.quote :=
+ #3 'after.sentence :=
+ #4 'after.quoted.block :=
+ #5 'after.block :=
+}
+
+STRINGS { s t }
+
+FUNCTION {output.nonnull}
+{ 's :=
+ output.state mid.sentence =
+ { ", " * write$ }
+ { output.state after.quote =
+ { " " * write$ }
+ { output.state after.block =
+ { add.period$ write$
+ newline$
+ "\newblock " write$
+ }
+ { output.state before.all =
+ 'write$
+ { output.state after.quoted.block =
+ { write$
+ newline$
+ "\newblock " write$
+ }
+ { add.period$ " " * write$ }
+ if$
+ }
+ if$
+ }
+ 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}
+{ newline$
+ "\bibitem{" write$
+ cite$ write$
+ "}" write$
+ newline$
+ ""
+ before.all 'output.state :=
+}
+
+FUNCTION {blank.sep}
+{ after.quote 'output.state :=
+}
+
+FUNCTION {fin.entry}
+{ output.state after.quoted.block =
+ 'skip$
+ 'add.period$
+ if$
+ write$
+ newline$
+}
+
+FUNCTION {new.block}
+{ output.state before.all =
+ 'skip$
+ { output.state after.quote =
+ { after.quoted.block 'output.state := }
+ { after.block 'output.state := }
+ if$
+ }
+ 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 {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 "{f.~}{vv~}{ll}{, jj}" format.name$ 't :=
+ nameptr #1 >
+ { namesleft #1 >
+ { ", " * t * }
+ { numnames #2 >
+ { "," * }
+ 'skip$
+ if$
+ t "others" =
+ { " {\em 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.eprint}
+{ eprint empty$
+ { ""}
+ { archive empty$
+ {"\href{http://xxx.lanl.gov/abs/" eprint * "}" *
+ "{{\tt " * eprint * "}}" *}
+ {"\href{http://xxx.lanl.gov/abs/" archive * "/" * eprint * "}" *
+ "{{\tt " * archive * "/" * eprint * "}}" *}
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.report}
+{ report empty$
+ { ""}
+ { report}
+ if$
+}
+
+
+
+FUNCTION {format.editors}
+{ editor empty$
+ { "" }
+ { editor format.names
+ editor num.names$ #1 >
+ { ", eds." * }
+ { ", ed." * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.title}
+{ title empty$
+ { "" }
+ { "``" title "t" change.case$ * ",''" * }
+ if$
+}
+
+FUNCTION {format.title.p}
+{ 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.date.paren}
+{ 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.collaboration}
+{ collaboration empty$
+ { "" }
+ { "{\bf " collaboration * "} " * "Collaboration" * }
+ 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$
+ { "" }
+ { "vol.~" volume *
+ 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 =
+ { "no.~" }
+ { "No.~" }
+ if$
+ number *
+ series empty$
+ { "there's a number but no series in " cite$ * warning$ }
+ { " in " * series * }
+ if$
+ }
+ if$
+ }
+ { "" }
+ if$
+}
+
+FUNCTION {format.edition}
+{ edition empty$
+ { "" }
+ { edition "l" change.case$ "~ed." * }
+ 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
+ { "pp.~" pages n.dashify * }
+ { "p.~" pages * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.pages.nopp}
+{ pages empty$
+ { "" }
+ { pages multi.page.check
+ { pages n.dashify }
+ { pages }
+ if$
+ }
+ if$
+}
+
+
+FUNCTION {format.volume}
+{ volume empty$
+ { "" }
+ { "{\bf " volume * "}" * }
+ if$
+}
+
+FUNCTION {format.number}
+{ number empty$
+ { "" }
+ { "no.~" number * }
+ if$
+}
+
+FUNCTION {format.chapter.pages}
+{ chapter empty$
+ 'format.pages
+ { type empty$
+ { "ch.~" chapter * }
+ { type "l" change.case$ chapter tie.or.space.connect }
+ if$
+ pages empty$
+ 'skip$
+ { ", " * format.pages * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.in.ed.booktitle}
+{ booktitle empty$
+ { "" }
+ { "in " booktitle emphasize *
+ editor empty$
+ 'skip$
+ { " (" * format.editors * ")" * }
+ if$
+ }
+ if$
+}
+
+FUNCTION {format.thesis.type}
+{ type empty$
+ 'skip$
+ { pop$
+ output.state after.block =
+ { type "t" change.case$ }
+ { type "l" change.case$ }
+ if$
+ }
+ if$
+}
+
+FUNCTION {empty.misc.check}
+{ author empty$ title empty$ howpublished empty$
+ month empty$ year empty$ note empty$
+ and and and and and
+ { "all relevant fields are empty in " cite$ * warning$ }
+ 'skip$
+ if$
+}
+
+FUNCTION {format.tr.number}
+{ type empty$
+ { "Tech. Rep." }
+ 'type
+ if$
+ number empty$
+ { "l" change.case$ }
+ { number tie.or.space.connect }
+ if$
+}
+
+FUNCTION {format.paddress}
+{ address empty$
+ { "" }
+ { "(" address * ")" * }
+ 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$ " {\em et.~al.}" * }
+ { #2 <
+ 'skip$
+ { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
+ { " {\em 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 "
+ }
+ { "Vol.~" volume *
+ " 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.collaboration output
+ format.authors "author" output.check
+ format.title "title" output.check
+ blank.sep
+ crossref missing$
+ { journal missing$
+ {}
+ { journal emphasize "journal" output.check
+ blank.sep
+ format.volume output
+ blank.sep
+ format.date.paren "year" output.check
+ month empty$
+ { format.number output }
+ 'skip$
+ if$
+ blank.sep
+ format.pages.nopp output
+ }
+ if$
+ report missing$
+ {format.eprint output}
+ {blank.sep format.report output format.eprint output}
+ if$
+ }
+ { format.article.crossref output.nonnull
+ format.pages output
+ format.eprint output
+ }
+ if$
+ new.sentence
+ note output
+ fin.entry
+}
+
+FUNCTION {book}
+{ output.bibitem
+ format.collaboration output
+ 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$
+ 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
+ note output
+ fin.entry
+}
+
+FUNCTION {booklet}
+{ output.bibitem
+ format.collaboration output
+ format.authors output
+ title empty$
+ { "empty title in " cite$ * warning$
+ howpublished new.sentence.checka
+ }
+ { howpublished empty$ not
+ address empty$ month empty$ year empty$ and and
+ or
+ { format.title.p output.nonnull }
+ { format.title output.nonnull }
+ if$
+ blank.sep
+ }
+ if$
+ howpublished output
+ address output
+ format.date output
+ new.block
+ note output
+ fin.entry
+}
+
+FUNCTION {inbook}
+{ output.bibitem
+ format.collaboration output
+ 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$
+ 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.block
+ 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
+ format.eprint output
+ new.block
+ note output
+ fin.entry
+}
+
+FUNCTION {incollection}
+{ output.bibitem
+ format.collaboration output
+ format.authors "author" output.check
+ format.title "title" output.check
+ blank.sep
+ crossref missing$
+ { format.in.ed.booktitle "booktitle" output.check
+ format.bvolume output
+ format.number.series output
+ format.chapter.pages output
+ new.block
+ 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
+ format.eprint output
+ new.block
+ note output
+ fin.entry
+}
+
+FUNCTION {inproceedings}
+{ output.bibitem
+ format.collaboration output
+ format.authors "author" output.check
+ format.title "title" output.check
+ blank.sep
+ crossref missing$
+ { format.in.ed.booktitle "booktitle" output.check
+ format.bvolume output
+ format.number.series output
+ format.paddress output
+ format.pages output
+ organization output
+ publisher output
+ format.date "year" output.check
+ }
+ { format.incoll.inproc.crossref output.nonnull
+ format.pages output
+ }
+ if$
+ new.block
+ format.eprint output
+ new.block
+ note output
+ fin.entry
+}
+
+FUNCTION {conference} { inproceedings }
+
+FUNCTION {manual}
+{ output.bibitem
+ format.collaboration output
+ author empty$
+ { organization empty$
+ 'skip$
+ { organization output.nonnull
+ address output
+ }
+ if$
+ }
+ { format.authors output.nonnull }
+ if$
+ 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
+ note output
+ fin.entry
+}
+
+FUNCTION {mastersthesis}
+{ output.bibitem
+ format.authors "author" output.check
+ format.title "title" output.check
+ blank.sep
+ "Master's thesis" format.thesis.type output.nonnull
+ school "school" output.check
+ address output
+ format.date "year" output.check
+ new.block
+ note output
+ fin.entry
+}
+
+FUNCTION {misc}
+{ output.bibitem
+ format.collaboration output
+ format.authors output
+ title empty$
+ { howpublished new.sentence.checka }
+ { howpublished empty$ not
+ month empty$ year empty$ and
+ or
+ { format.title.p output.nonnull }
+ { format.title output.nonnull }
+ if$
+ blank.sep
+ }
+ if$
+ howpublished output
+ format.date output
+ new.block
+ note output
+ fin.entry
+ empty.misc.check
+}
+
+FUNCTION {phdthesis}
+{ output.bibitem
+ format.authors "author" output.check
+ 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
+ format.eprint output
+ new.block
+ note output
+ fin.entry
+}
+
+FUNCTION {proceedings}
+{ output.bibitem
+ editor empty$
+ { organization output }
+ { format.editors output.nonnull }
+ if$
+ format.btitle "title" output.check
+ format.bvolume output
+ format.number.series output
+ format.paddress output
+ editor empty$
+ 'skip$
+ { organization output }
+ if$
+ publisher output
+ format.date "year" output.check
+ new.block
+ note output
+ fin.entry
+}
+
+FUNCTION {techreport}
+{ output.bibitem
+ format.collaboration output
+ format.authors "author" output.check
+ format.title "title" output.check
+ blank.sep
+ format.tr.number output.nonnull
+ institution "institution" output.check
+ address output
+ format.date "year" output.check
+ new.block
+ note output
+ fin.entry
+}
+
+FUNCTION {unpublished}
+{ output.bibitem
+ format.collaboration output
+ format.authors "author" output.check
+ format.title.p "title" output.check
+ blank.sep
+ note "note" output.check
+ format.date output
+ fin.entry
+}
+
+FUNCTION {default.type} { misc }
+
+MACRO {jan} {"Jan."}
+
+MACRO {feb} {"Feb."}
+
+MACRO {mar} {"Mar."}
+
+MACRO {apr} {"Apr."}
+
+MACRO {may} {"May"}
+
+MACRO {jun} {"June"}
+
+MACRO {jul} {"July"}
+
+MACRO {aug} {"Aug."}
+
+MACRO {sep} {"Sept."}
+
+MACRO {oct} {"Oct."}
+
+MACRO {nov} {"Nov."}
+
+MACRO {dec} {"Dec."}
+
+MACRO {nup} {"Nucl. Phys."}
+
+MACRO {cmp} {"Comm. Math. Phys."}
+
+MACRO {prl} {"Phys. Rev. Lett."}
+
+MACRO {pl} {"Phys. Lett."}
+
+MACRO {rmp} {"Rev. Mod. Phys."}
+
+MACRO {ijmp} {"Int. Jour. Mod. Phys."}
+
+MACRO {mpl} {"Mod. Phys. Lett."}
+
+MACRO {pr} {"Phys. Rev."}
+
+READ
+
+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}
+
+FUNCTION {begin.bib}
+{ preamble$ empty$
+ 'skip$
+ { preamble$ write$ newline$ }
+ if$
+ "\providecommand{\href}[2]{#2}"
+ "\begingroup\raggedright\begin{thebibliography}{" * longest.label *
+ "}" * write$ newline$ }
+
+EXECUTE {begin.bib}
+
+EXECUTE {init.state.consts}
+
+ITERATE {call.type$}
+
+FUNCTION {end.bib}
+{ newline$
+ "\end{thebibliography}\endgroup" write$ newline$
+}
+
+EXECUTE {end.bib}