[comp.text.tex] program to manage BiBTeX database ???

rein@fwi.uva.nl (Rein van den Boomgaard) (04/19/91)

I've collected quite a few references in a bibtex file
now, but still i never seem to learn to what fields are required
for which entries etc.

Is there a kind database program available which does the 
work (menu's, dialogues, etc etc) and which allows me to
search in the database as well as add new items ???

I have a PC at home and UNIX computers at work, so a program
for either one is fine (best of all a program working on both).

Public domain of course (or shareware).

Thanks,

	Rein van den Boomgaard
  	rein@fwi.uva.nl		
-- 
				


				 Rein van den Boomgaard

king@cs.uq.oz.au (Paul King) (04/20/91)

rein@fwi.uva.nl (Rein van den Boomgaard) writes:

>Is there a kind database program available which does the 
>work (menu's, dialogues, etc etc) and which allows me to
>search in the database as well as add new items ???

Here is a copy of btt, a package for managing BibTeX databases.
(btt has only changed slightly since it was posted late last year.
So you probably don't need to recopy it if your already have it.
I have had a number of requests for it, so I am posting it again.)

It includes a UNIX shell script (the main program), a number of C programs
and some other TeX related files.
The C programs are modified versions of some files sent to comp.text a long
while ago, which I got second hand.  They were originally called addbibtex,
sortbibtex and lookbibtex, and written by Kristof Nast-Kolb, who was at the
Technical University Munic, Institut fuer Informatik, Germany at the time.

Here is a brief overview of btt (BibTex Tool).

btt options:

        Add     add bib entries or strings to database
        Find    search for bib entries
        Info    gives number of bibtex entries and string abbreviations, etc
        List    list entries, strings, keys, style macros
        Print   print hard copy of bibliography
        Quit    quit btt
        Sort    sort bib entries

Typing `?' and <return> at most prompts gives help info, including
the above overview, how to enter abbreviations and other shortcuts,
the info about standard entry types given in the LaTeX manual and the
info about each entry type.

>I have a PC at home and UNIX computers at work, so a program
>for either one is fine (best of all a program working on both).

The C files should work on both systems, you may want to write a
batch file on the PC to replace the btt UNIX script however.

Hope this helps, Paul.
---------
Paul King                                                              _--_|\
Dept. of Computer Science, Univ. of Queensland                        /      X
Queensland, Australia, 4072                                           \_.--._/
king@cs.uq.oz.au (ACSNET)                                                   v

--------------------cut here-------------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  btt/Makefile btt/README btt/bibadd.1l btt/bibadd.c
#   btt/bibadjust.c btt/bibgrep.1l btt/bibgrep.c btt/bibsort.1l
#   btt/bibsort.c btt/btt btt/cite.bst btt/printbib.sty
# Wrapped by king@tardis on Sat Apr 20 08:08:40 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'btt/Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'btt/Makefile'\"
else
echo shar: Extracting \"'btt/Makefile'\" \(392 characters\)
sed "s/^X//" >'btt/Makefile' <<'END_OF_FILE'
X
XSRC= bibadjust.c bibadd.c bibgrep.c bibsort.c
XEXE= bibadjust bibadd bibgrep bibsort
X
XBSDORSYSV = BSD
X
XCFLAGS = -O2 -D$(BSDORSYSV)
X
Xall: $(EXE)
X
Xclean:
X	/bin/rm -f $(EXE)
Xbibadd:		bibadd.c
X	cc $(CFLAGS) -o bibadd bibadd.c
Xbibsort:	bibsort.c
X	cc $(CFLAGS) -o bibsort bibsort.c
Xbibgrep:	bibgrep.c
X	cc $(CFLAGS) -o bibgrep bibgrep.c
Xbibadjust:	bibadjust.c
X	cc $(CFLAGS) -o bibadjust bibadjust.c
END_OF_FILE
if test 392 -ne `wc -c <'btt/Makefile'`; then
    echo shar: \"'btt/Makefile'\" unpacked with wrong size!
fi
# end of 'btt/Makefile'
fi
if test -f 'btt/README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'btt/README'\"
else
echo shar: Extracting \"'btt/README'\" \(1094 characters\)
sed "s/^X//" >'btt/README' <<'END_OF_FILE'
Xbtt is a package for managing BibTeX databases.
X
XIt includes a UNIX shell script (the main program), a number of C programs
Xand some other TeX related files.
XThe C programs are modified versions of some files sent to comp.text a long
Xwhile ago, which I got second hand.  They were originally called addbibtex,
Xsortbibtex and lookbibtex, and written by Kristof Nast-Kolb, who was at the
XTechnical University Munic, Institut fuer Informatik, Germany at the time.
X
XHere is a brief overview of btt (BibTex Tool).
X
Xbtt options:
X
X        Add     add bib entries or strings to database
X        Find    search for bib entries
X        Info    gives number of bibtex entries and string abbreviations, etc
X        List    list entries, strings, keys, style macros
X        Print   print hard copy of bibliography
X        Quit    quit btt
X        Sort    sort bib entries
X
XTyping `?' and <return> at most prompts gives help info, including
Xthe above overview, how to enter abbreviations and other shortcuts,
Xthe info about standard entry types given in the LaTeX manual and the
Xinfo about each entry type.
X
END_OF_FILE
if test 1094 -ne `wc -c <'btt/README'`; then
    echo shar: \"'btt/README'\" unpacked with wrong size!
fi
# end of 'btt/README'
fi
if test -f 'btt/bibadd.1l' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'btt/bibadd.1l'\"
else
echo shar: Extracting \"'btt/bibadd.1l'\" \(1137 characters\)
sed "s/^X//" >'btt/bibadd.1l' <<'END_OF_FILE'
X.TH BIBADD 1l LOCAL
X.SH NAME
Xbibadd \- Enter data into a BIBTeX database
X.sp
X.SH SYNOPSIS
X\fBbibadd  \fI [-p promptfile] [-k] <file>\fR
X.sp
X.SH DESCRIPTION
X.I
Xbibadd
Xallows easy creation of a BIBTeX database. The type, the "cite" reference
Xand the type-specific information are interactively prompted for.
XThe optional \fIpromptfile\fR can be used to make
X.I bibadd
Xprompt for special type-independent fields. The \fIpromptfile\fR
Xmust contain one field name per line. The following type names are
Xavailable to
X.I bibadd
X(abbreviations in parentheses):
X.br
Xarticle(a), book(b), booklet(bl), conference(c), inbook(ib),
Xincollection(ic), inproceedings(i), manual(m), masterthesis(mt),
Xmisc(mi), phdthesis(ph), proceedings(p), techreport(t),
Xunpublished(u) as well as strings(s)
X.sp
XNormally the key field is not prompted for, but with the -k option,
X.I bibadd
Xwill ask for the \fIkey\fR field after the \fIcite\fR prompt.
XThe \fIkey\fR field is used to describe the entry in the \fIalpha\fR
Xbibliography style.
X.sp
XHelp about using
X.I bibadd
Xcan be obtained by typing '?' to the add options prompt.
X.SH "SEE ALSO"
Xbibsort(1l), bibgrep(1l)
END_OF_FILE
if test 1137 -ne `wc -c <'btt/bibadd.1l'`; then
    echo shar: \"'btt/bibadd.1l'\" unpacked with wrong size!
fi
# end of 'btt/bibadd.1l'
fi
if test -f 'btt/bibadd.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'btt/bibadd.c'\"
else
echo shar: Extracting \"'btt/bibadd.c'\" \(18277 characters\)
sed "s/^X//" >'btt/bibadd.c' <<'END_OF_FILE'
X/* tool for BiBTeX databases */
X
X#include <stdio.h>
X#include <ctype.h>
X#include <signal.h>
X#ifdef SYSV
X#include <string.h>
X#endif
X#ifdef BSD
X#include <strings.h>
X#endif
X
X#define BUFLEN 2048	/* maximum characters in a field		*/
X#define MAXENT 50	/* max. number of entry types			*/
X#define MAXLEN 30	/* is max. length of fieldnames			*/
X#define STDENT 25	/* number of standard entry types (including 0)	*/
X#define MAXTYPES 20	/* max. number of field combinations		*/
X#define MAXFIELDS 20	/* max. number of fields per type		*/
X#define HELPLEN 320	/* 4 * 80 col lines of help for each entry	*/
X#define TABNEEDED 4	/* maximum width of field needing extra tab	*/
X#define DEFAULT_EDITOR "vi"	/* default editor			*/
X
Xchar fieldname[MAXENT][MAXLEN] = {
X	"address",			/* 0 */
X	"annote",			/* 1 */
X	"author",			/* 2 */
X	"booktitle",			/* 3 */
X	"chapter",			/* 4 */
X	"edition",			/* 5 */
X	"editor",			/* 6 */
X	"howpublished",			/* 7 */
X	"institution",			/* 8 */
X	"journal",			/* 9 */
X	"key",				/* 10 */
X	"month",			/* 11 */
X	"note",				/* 12 */
X	"number",			/* 13 */
X	"organization",			/* 14 */
X	"pages",			/* 15 */
X	"publisher",			/* 16 */
X	"school",			/* 17 */
X	"series",			/* 18 */
X	"title",			/* 19 */
X	"type",				/* 20 */
X	"volume",			/* 21 */
X	"year",				/* 22 */
X	"crossref",			/* 23 */
X	"comment"			/* 24 */
X};
X
Xchar helpprompt[MAXENT][HELPLEN] = {
X/* 0 */
X"Publisher's address. For major publishing houses, just the city\n\
X is given, for smaller publishers, you might choose to give the\n\
X full address.",
X/* 1 */
X"An annotation. Not used in the standard bibliography styles, but\n\
X may be used by others.",
X/* 2 */
X"The name(s) of the author(s).  Separate multiple authors by the\n\
X keyword 'and'.  See the LaTeX manual for more help.",
X/* 3 */
X"Title of the book, part of which is being cited.",
X/* 4 */
X"A chapter number.",
X/* 5 */
X"The edition of the book--for example, 'second'.",
X/* 6 */
X"Name(s) of editor(s), typed as in the author field.  If the author\n\
X is also indicated, then this field gives the editor of the book or\n\
X collection in which the reference appears.",
X/* 7 */
X"How something strange has been published.",
X/* 8 */
X"The institution that published the work.",
X/* 9 */
X"The name of a journal.",
X/* 10 */
X"Used for alphabetising and creating a label when the author and\n\
X editor fields are missing.",
X/* 11 */
X"The month in which the work was published.  For an unpublished\n\
X work, the month in which it was written.",
X/* 12 */
X"Any additional information that can help the reader.",
X/* 13 */
X"The number of a journal, magazine or technical report.",
X/* 14 */
X"The organisation sponsoring the conference.",
X/* 15 */
X"One or more page numbers, or range of page numbers, as 42--111,\n\
X or 7,41,73--97.",
X/* 16 */
X"The publisher's name.",
X/* 17 */
X"The name of the school in which the thesis was written.",
X/* 18 */
X"The name of a series or set of books.",
X/* 19 */
X"The work's title",
X/* 20 */
X"The type of a technical report, e.g. 'Research Note' or 'Draft Report'.",
X/* 21 */
X"The volume of a journal or multivolume work.",
X/* 22 */
X"The year of publication, or for an unpublished work, the year in\n\
X which it was written.",
X/* 23 */
X"used to fill in missing field info in this record from the\n\
X cross-referenced bib-record..see BiBTeXing manual for more help.",
X/* 24 */
X"Any relevant info associated with this record that you would like\n\
X to store herein."
X};		
X
X/* no. are similar to indices in entry_field, e.g. 2=author */
X/* key (10) must be the first index */
Xint typepr[MAXTYPES][MAXFIELDS] = {
X  10, 2,19, 9,21,13,15,11,22, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* article */
X  10, 2, 6,19,16,11,22,21,13,18, 0, 5, 1,-1,-1,-1,-1,-1,-1,-1, /* book */
X  10, 2,19, 7, 0,11,22, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* booklet */
X  10, 2, 6,19, 4,15,16,11,22,21,13,18,20, 0, 5,23, 1,-1,-1,-1, /* inbook */
X  10, 2,19, 3,16,11,22,21,13,20, 6, 4,15, 0,18, 5,23, 1,-1,-1, /* incollectn */
X  10, 2,19, 3,11,22, 0,15,18,21,13, 6,14,16,23, 1,-1,-1,-1,-1, /* inprcdings */
X  10,19, 2,14, 0,11,22, 5, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* manual */
X  10, 2,19,17,11,22, 0,20, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* msthesis */
X  10, 2,19, 7,11,22, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* misc */
X  10, 2,19,17,11,22, 0,20, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* phdthesis */
X  10,19,11,22,21,13, 0, 6,16,14,18, 1,-1,-1,-1,-1,-1,-1,-1,-1, /* proceedings */
X  10, 2,19, 8,11,22,20,13, 0, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* techreport */
X  10, 2,19,11,22, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* unpublished */
X  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
X  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
X  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
X  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
X  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
X  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
X  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 };
X
X#define	RQ	MAXENT		/* required field */
X#define	OP	-MAXENT		/* optional field */
X#define	ARQ	3*MAXENT	/* required field and/or other */
X#define	XRQ	2*MAXENT	/* required field or other */
X#define	XOP	-2*MAXENT	/* optional field or other */
X
X	/* entries are similar to type-field, +/- indices for "or",
X	   RQ + index for "and/or" */
Xint required[MAXTYPES][MAXFIELDS] = {
X  OP,RQ,RQ,RQ,OP,OP,OP,OP,RQ,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP, /* article */
X  OP, 6,XRQ,RQ,RQ,OP,RQ,-13,XOP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP, /* book */
X  OP,OP,RQ,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP, /* booklet */
X  OP,6,XRQ,RQ,RQ+15,ARQ,OP,OP,RQ,-13,XOP,OP,OP,OP,OP,OP,OP,OP,OP,OP, /* inbk */
X  OP,RQ,RQ,RQ,RQ,OP,RQ,-13,XOP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP, /* incollctn */
X  OP,RQ,RQ,RQ,OP,RQ,OP,OP,OP,-13,XOP,OP,OP,OP,OP,OP,OP,OP,OP,OP, /* inprcdngs */
X  OP,RQ,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP, /* manual */
X  OP,RQ,RQ,RQ,OP,RQ,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP, /* msthesis */
X  OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP, /* misc */
X  OP,RQ,RQ,RQ,OP,RQ,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP, /* phdthesis */
X  OP,RQ,OP,RQ,-13,XOP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP, /* procdings */
X  OP,RQ,RQ,RQ,OP,RQ,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP, /* techreport */
X  OP,RQ,RQ,RQ,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP, /* unpublished */
X  OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,
X  OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,
X  OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,
X  OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,
X  OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,
X  OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,
X  OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP,OP};
X
Xint nokey;			/* prompt for key ? (default is no) */
Xchar linebuf[BUFLEN];		/* input buffer */
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X	int i;
X
X	nokey = 1;
X	if (argc == 1)
X	{
X	    fprintf(stderr,"%s: no bibliography file specified\n", argv[0]);
X	    usage(argv[0]);
X	}
X	for (i = 1; argv[i][0] == '-'; i++)
X	{
X		if (argv[i][1] == 'p')
X		{
X			if (i >= argc - 2)
X			{
X			    fprintf(stderr,"%s: no promptfile specified\n", argv[0]);
X			    usage(argv[0]);
X			}
X			add_prompts(argv[++i]);
X		}
X		else if (argv[i][1] == 'k')
X			nokey=0;
X		else  /* neither -p nor -k */
X		{
X			fprintf(stderr,"%s: unknown option: %s\n", argv[0], argv[i]);
X			usage(argv[0]);
X		}
X	}
X	if (i < argc - 1)
X	{
X		fprintf(stderr,"%s: too many arguments\n", argv[0]);
X		usage(argv[0]);
X	}
X		addbibtex(argv[i]);
X}
X
Xusage(name)  /* display usage message */
Xchar *name;
X{
X    fprintf(stderr,"usage: %s [-p promptfile] [-k] bibfile\n", name);
X    exit(1);
X}
X
Xaddbibtex(arg)	/* add entries to a bibtex database file */
Xchar *arg;
X{
X	FILE *fp, *fopen();
X	char field[MAXLEN];
X	int i = 0, type, isexor;
X
X	for (;;) {
X		/* append to the file */
X		if ((fp = fopen(arg, "a")) == NULL)
X		{
X			perror(arg);
X			exit(1);
X		}
X
X		/* get type of entry */
X		printf("add options: Article,Book,BookLet,Conference,Inproceedings,InBook,InCollection,\n  Manual,MastersThesis,MIsc,Proceedings,PHdthesis,String,Techreport,Unpublished\n\nentry type = ");
X		if (fgets(linebuf, BUFLEN, stdin) == NULL)
X		{
X			clearerr(stdin);
X			fclosebibfile(fp, arg);
X			return;
X		}
X		switch (linebuf[0]) {
X		case 'a':
X		case 'A':
X			type = 0;
X			fprintf(fp, "@article{"); /* } */
X			break;
X		case 'b':
X		case 'B':
X			if (linebuf[1] == 'l' || linebuf[4] == 'l' ||
X			    linebuf[1] == 'L' || linebuf[4] == 'L') {
X				type = 2;
X				fprintf(fp, "@booklet{"); /* } */
X				break;
X			}
X			type = 1;
X			fprintf(fp, "@book{"); /* } */
X			break;
X		case 'c':
X		case 'C':
X			type = 5;
X			fprintf(fp, "@conference{"); /* } */
X			break;
X		case 'h':
X		case 'H':
X		case '?':
X			fclosebibfile(fp, arg);
X			help();
X			continue;
X		case 'i':
X		case 'I':
X			if (linebuf[1] == 'b' || linebuf[2] == 'b' ||
X			    linebuf[1] == 'B' || linebuf[2] == 'B') {
X				type = 3;
X				fprintf(fp, "@inbook{"); /* } */
X				break;
X			}
X			else if (linebuf[1] == 'c' || linebuf[2] == 'c' ||
X				 linebuf[1] == 'C' || linebuf[2] == 'C') {
X				type = 4;
X				fprintf(fp, "@incollection{"); /* } */
X				break;
X			}
X			type = 5;
X			fprintf(fp, "@inproceedings{"); /* } */
X			break;
X		case 'm':
X		case 'M':
X			if (linebuf[1] == 't' || linebuf[3] == 't' ||
X			    linebuf[1] == 'T' || linebuf[3] == 'T') {
X				type = 7;
X				fprintf(fp, "@mastersthesis{"); /* } */
X				break;
X			}
X			else if (linebuf[1] == 'i' || linebuf[1] == 'I') {
X				type = 8;
X				fprintf(fp, "@misc{"); /* } */
X				break;
X			}
X			type = 6;
X			fprintf(fp, "@manual{"); /* } */
X			break;
X		case 'p':
X		case 'P':
X			if (linebuf[1] == 'h' || linebuf[1] == 'H') {
X				type = 9;
X				fprintf(fp, "@phdthesis{"); /* } */
X				break;
X			}
X			type = 10;
X			fprintf(fp, "@proceedings{"); /* } */
X			break;
X		case 'q':
X		case 'Q':
X		case '\n':
X			fclosebibfile(fp, arg);
X			return;
X		case 's':
X		case 'S':
X			/* get string keyword */
X			printf("string keyword = ");
X			fgets(linebuf, BUFLEN, stdin);
X			del_space(linebuf);
X			fprintf(fp, "@string{%s = {", linebuf);
X
X			/* get string text */
X			printf("string text = ");
X			fgets(linebuf, BUFLEN, stdin);
X			del_space(linebuf);
X			fprintf(fp, "%s}}\n", linebuf);
X
X			fclosebibfile(fp, arg);
X			return;
X		case 't':
X		case 'T':
X			type = 11;
X			fprintf(fp, "@techreport{"); /* } */
X			break;
X		case 'u':
X		case 'U':
X			type = 12;
X			fprintf(fp, "@unpublished{"); /* } */
X			break;
X		default:
X			fprintf(stderr, "invalid option, try again (? for help)\n\n");
X			fclosebibfile(fp, arg);
X			continue;
X		}
X
X		/* get cite keyword */
X		printf("cite = ");
X		fgets(linebuf, BUFLEN, stdin);
X		del_space(linebuf);
X		fprintf(fp, "%s", linebuf);
X
X		/* now get the remaining fields */
X		isexor=0;
X		for (i = nokey; i < MAXFIELDS && typepr[type][i] != -1; i++)
X		{
X			if (required[type][i] < 0) {
X			    if (required[type][i] != OP) {
X				if (required[type][i] != XOP) {
X				    isexor=1;
X				    printf("(or %s) ",
X				       fieldname[-required[type][i]]);
X				}
X				else if (isexor) {
X				    isexor=0;
X				    continue;
X				}
X			    }
X			}
X			else if (required[type][i] < RQ) {
X				isexor=1;
X				printf("* (or %s) ",
X				       fieldname[required[type][i]]);
X			}
X			else if (required[type][i] == RQ)
X				printf("* ");
X			else if (required[type][i] == XRQ) {
X				if (isexor) {
X				    isexor=0;
X				    continue;
X				}
X				else
X				    printf("* ");
X			}
X			else if (required[type][i] == ARQ) {
X				if (isexor) {
X				    isexor=0;
X				}
X				else
X				    printf("* ");
X			}
X			else {
X				isexor=1;
X				printf("* (and/or %s) ",
X				       fieldname[required[type][i]-RQ]);
X			}
X			printf("%s = ", fieldname[typepr[type][i]]);
X			if (fgets(linebuf, BUFLEN, stdin) == NULL)
X			{
X				clearerr(stdin);
X				break;
X			}
X			else if (linebuf[0] == '.' && linebuf[1] == '\n')
X				break;
X			else if (linebuf[0] == '?' && linebuf[1] == '\n') {
X				printf("%s\n", helpprompt[typepr[type][i]]);
X				i--;
X				continue;
X			}
X			else if (linebuf[strlen(linebuf)-2] == '+')
X			{
X				if (linebuf[0] != '+')
X				{
X				    linebuf[strlen(linebuf)-2] = '\n';
X				    linebuf[strlen(linebuf)-1] = NULL;
X				    del_space(linebuf);
X				    fprintfield(fp, fieldname[typepr[type][i]], linebuf);
X				} else
X					i--;
X				again:
X				printf("fieldname = ");
X				fgets(field, MAXLEN, stdin);
X				del_space(field);
X				printf("%s = ",field);
X				fgets(linebuf, BUFLEN, stdin);
X				if (linebuf[strlen(linebuf)-2] == '+')
X				{
X				    if (linebuf[0] != '+')
X				    {
X					linebuf[strlen(linebuf)-2] = '\n';
X					linebuf[strlen(linebuf)-1] = NULL;
X					del_space(linebuf);
X					fprintfield(fp, field, linebuf);
X				    }
X				    goto again;
X				}
X				del_space(linebuf);
X				fprintfield(fp, field, linebuf);
X			}
X			else if (linebuf[0] != '\n') {
X				del_space(linebuf);
X				fprintfield(fp, fieldname[typepr[type][i]], linebuf);
X			}
X			else
X			    isexor=0;
X		} /* { */
X
X		/* close off the entry */
X		fprintf(fp, "\n}\n");
X		/* close off file so it can be edited  --  this might
X		   be considered inefficient, but is probably safer. */
X		fclosebibfile(fp, arg);
X		return;
X	}
X}
X
Xfclosebibfile(fp, arg)	/* close bibfile and check for error */
XFILE *fp;
Xchar *arg;
X{
X	fclose(fp);
X	if (ferror(fp))
X	{
X		perror(arg);
X		exit(1);
X	}
X}
X
Xdel_space(linebuf)	/* delete space at end of linebuf */
Xchar linebuf[];
X{
X	int n;
X
X	n = strlen(linebuf);
X	while (--n >= 0)
X	{
X		if (!isspace(linebuf[n]))
X			break;
X	}
X	linebuf[++n] = NULL;
X	return;
X}
X
Xadd_prompts(arg)
Xchar *arg;
X{
X	FILE *prr, *fopen();
X	char str[BUFLEN];
X	int entry, i, j;
X
X	if ((prr = fopen(arg, "r")) == NULL)
X	{
X		fprintf(stderr, "Can't open promptfile \n");
X		exit(1);
X	}
X	for (entry = STDENT; fgets(str, BUFLEN, prr); entry++)
X	{
X		for (i = 0; i < MAXLEN && str[i] != '\n'; i++) {
X			fieldname[entry][i] = str[i];
X		}
X		if (i == MAXLEN)
X			fprintf(stderr, "field %s in promptfile too long (cut)\n",str);
X		for (i=0 ; i < MAXTYPES && typepr[i][0] != -1 ; i++) {
X			for (j=0 ; j < MAXFIELDS && typepr[i][j] != -1
X			     ; j++) ;
X			if (j < MAXFIELDS)
X				typepr[i][j] = entry;
X			else
X				fprintf(stderr, "Too many prompts for %s.\n",fieldname[i]);
X		}
X
X		if (entry >= MAXENT)
X		{
X			fprintf(stderr, "Too many entries (%d) in promptfile\n",entry);
X			exit(1);
X		}
X	}
X	fclose(prr);
X	return;
X}
X
Xhelp()		/* some instructions */
X{
X  printf("\nYou will first be prompted for the entry type (you can abbreviate using the\ngiven capitalised letters, like mi for MIsc or i for Inproceedings).");
X
X  printf("\n\nThen you get a prompt for the cite and the special bibliographic fields for\nthis entry (required fields have a `*', fields which have to be used\nalternatively, are written in brackets).");
X
X  printf("\n\nFor help info about the current field, type '?' then RETURN.");
X  printf("\nIf you don't need a particular field, just hit RETURN.");
X  printf("\nTo finish an entry early, type `.' then RETURN.");
X  printf("\nTo add an unusual field, type `+' at the end of a field.");
X
X  printf("\n\nNormally each field will automatically be surrounded by braces.");
X  printf("\n\tTo suppress the braces, start the field with a `#'.");
X  printf("\n\tThis is useful for macro and string abbreviations or where you");
X  printf("\n\twish to have control over the entry's delimeters");
X  printf("\n\te.g.        jan,     #jan,   #pstv#{ IX},   #\"A.U. Thor\"");
X  printf("\n\tproduce:    {jan},   jan,    pstv#{ IX},    \"A.U. Thor\".\n\nUse the `String' add option to enter your own string abbreviations which\n\tyou can use by entering #abbrevname when prompted for a field.\n\nmore (y/n)?");
X
X  if (fgets(linebuf, BUFLEN, stdin) == NULL)
X  {
X	clearerr(stdin);
X	return;
X  }
X
X  if (linebuf[0] == 'n' || linebuf[0] == 'N') {
X	printf("\n");
X	return;
X  }
X
X  printf("\nStandard entry types:\n\n");
X  printf("article		an article from a journal or magazine\n");
X  printf("book		a book with an explicit publisher\n");
X  printf("booklet		a work that is printed and bound, but without a named publisher\n		or sponsoring institution\n");
X  printf("conference	the same as inproceedings\n");
X  printf("inbook		a part of a book, which may be a chapter and/or a range of pages\n");
X  printf("incollection	a part of a book with its own title\n");
X  printf("inproceedings	an article in a conference proceedings\n");
X  printf("manual		technical documentation\n");
X  printf("mastersthesis	a Master's thesis\n");
X  printf("misc		use this type when nothing else fits\n");
X  printf("phdthesis	a Ph.D. thesis\n");
X  printf("proceedings	the proceedings of a conference\n");
X  printf("techreport	a report published by a school or other institution,\n		usually numbered within a series\n");
X  printf("unpublished	a document with an author and title, but not formally published\n\n");
X  return;
X}
X
Xfprintfield(fp, fieldname, fieldvalue)	/* printf prompt for field */
XFILE *fp;
Xchar *fieldname, *fieldvalue;
X{
X	int i,num;
X
X	fprintf(fp, ",\n\t%s = ", fieldname);
X	if (strlen(fieldname) <= TABNEEDED)
X		fprintf(fp, "\t\t");
X	else
X		fprintf(fp, "\t");
X	if (fieldvalue[0] == '#')
X		fprintf(fp, "%s", &fieldvalue[1]);
X	else {
X		for (i=0,num=1;i<strlen(fieldvalue);i++)
X			if (isdigit(fieldvalue[i]))
X				continue;
X			else {
X				num = 0;
X				break;
X			}
X		if (num)
X			fprintf(fp, "%s", fieldvalue);
X		else
X			fprintf(fp, "{%s}", fieldvalue);
X	}
X}
X
Xprintfield(field, value)	/* printf prompt for field */
Xchar *field, *value;
X{
X	fprintfield(stdout, field, value);
X}
X
Xeditfile(edfile)		/* edit file */
Xchar *edfile;
X{
X	char *EDITOR, *getenv();
X	int editorpid;
X
X	EDITOR = getenv ("TEXEDIT");
X	if (! EDITOR) EDITOR = getenv ("VISUAL");
X	if (! EDITOR) EDITOR = getenv ("EDITOR");
X	if (! EDITOR) EDITOR = DEFAULT_EDITOR;
X
X	editorpid = fork();
X	if (editorpid < 0) {
X		perror ("Cannot fork Editor");
X		exit (-2);
X	} else if (editorpid == 0) {	/* CHILD */
X		if (EDITOR[strlen(EDITOR)-2] == 'v' &&
X		    EDITOR[strlen(EDITOR)-1] == 'i')
X			execlp(EDITOR, EDITOR, "+$", edfile, (char *) NULL);
X		else /* other editor */
X			execlp(EDITOR, EDITOR, edfile, (char *) NULL);
X		perror ("Cannot exec EDITOR, using DEFAULT_EDITOR");
X		execlp (DEFAULT_EDITOR, DEFAULT_EDITOR, edfile, (char *) NULL);
X		perror ("Cannot exec DEFAULT_EDITOR, giving up");
X		exit (-3);
X	} else
X		(void) wait ((union wait *) 0);
X}
END_OF_FILE
if test 18277 -ne `wc -c <'btt/bibadd.c'`; then
    echo shar: \"'btt/bibadd.c'\" unpacked with wrong size!
fi
# end of 'btt/bibadd.c'
fi
if test -f 'btt/bibadjust.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'btt/bibadjust.c'\"
else
echo shar: Extracting \"'btt/bibadjust.c'\" \(2746 characters\)
sed "s/^X//" >'btt/bibadjust.c' <<'END_OF_FILE'
X/* bibadjust.c */
X
X#include <stdio.h>
X#ifdef SYSV
X#include <string.h>
X#define index strchr
X#endif
X#ifdef BSD
X#include <strings.h>
X#endif
X#include <ctype.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
XFILE * in;
X#define BUFLEN 4000
X#define STRLEN 800
X
Xextern char *getenv();
X
Xmain (argc, argv)
Xint argc;
Xchar * argv[];
X{
X	FILE * fopen();
X	int ret ,length, iseof, lnlen, i;
X	struct stat stbuf;
X	char buf[BUFLEN];
X	char filename[STRLEN];
X	char actstr[STRLEN];
X	char *texinputs, *top, *end;
X
X	if (argc <= 1) usageerr();
X	texinputs = getenv("TEXINPUTS");
X	while (--argc,++argv, argc>0 ) {
X		if ((texinputs != NULL) && (**argv != '/')) {
X			if (STRLEN <= (strlen(texinputs) + strlen(*argv)))
X			  fprintf(stderr, "Warning: Environment String too long\n");
X			strncpy(actstr,texinputs,STRLEN);
X			top = actstr;
X			end = actstr;
X			ret = -1;
X			while (end != NULL) { /* evaluate TEXINPUTS */
X				end = index(top,':'); /* Search for first : */
X				if (end != NULL) *end = '\0'; /* modify : to \0 */
X				strncpy(filename,top,STRLEN);
X				if (end != NULL) top = ++end;
X				if (!(length = strlen(filename))) continue;
X				filename[length++] = '/';
X				filename[length] = '\0';
X				strcat(filename,*argv);
X				if ((ret = stat(filename,&stbuf)) ==  0)  break;
X			}
X			if (ret < 0) {
X				fprintf(stderr,"file not found: %s\n",*argv);
X				continue;
X			}
X		}
X		else strcpy(filename,*argv); /* TEXINPUTS was not set or filename
X					begins with a / */
X
X		if (stat(filename,&stbuf) < 0) {
X			fprintf(stderr,"file not found: %s\n",filename);
X			continue;
X		}
X		if ((stbuf.st_mode & S_IFMT) != S_IFREG) {
X			fprintf(stderr," %s is not an ordinary file\n",filename);
X			continue;
X		}
X		if ((in=fopen(filename,"r")) == NULL) {
X			fprintf(stderr,"%s can not be opened\n",filename);
X			continue;
X		}
X		lnlen = 0;
X		while (1) {
X		    iseof = getline(buf,&lnlen);
X		    if (strncmp(buf,"@string",7)) {
X			for (i=lnlen-1; i>0 ; i--)
X				if (buf[i] == '}' || buf[i] == ')') break;
X			if (buf[i-1] != '\n') {
X				buf[i+2] = '\n';
X				buf[i+1] = buf[i];
X				buf[i] = '\n';
X				lnlen = i + 3;
X			}
X		    }
X		    for (i=0 ; i<lnlen ; i++) putchar(buf[i]);
X		    if (iseof == EOF) break;
X		}
X	}
X	exit(0);
X}
X
Xint getline(line,len)
Xchar * line;
Xint * len;
X{
X	int count = 0;
X	int startline = 0;
X
X	if ((*line = getc(in)) == EOF)
X		return(EOF);
X	else
X	    count++, line++;
X	while ((*line = getc(in)) != EOF) {
X		if (*line == '@' && startline) break;
X		if (*line == '\n')
X			startline = 1;
X		else
X			startline = 0;
X		count++;
X		line++;
X		if (count > BUFLEN) {
X			fprintf(stderr,"Entry too long\n");
X			exit(1);
X		}
X	}
X	*len = count;
X	if (*line == EOF)
X		return(EOF);
X	else
X		ungetc(*line, in);
X	return(count);
X}
X
Xusageerr()
X{
X	fprintf(stderr,"usage:bibadjust <files>\n");
X	exit(1);
X}
END_OF_FILE
if test 2746 -ne `wc -c <'btt/bibadjust.c'`; then
    echo shar: \"'btt/bibadjust.c'\" unpacked with wrong size!
fi
# end of 'btt/bibadjust.c'
fi
if test -f 'btt/bibgrep.1l' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'btt/bibgrep.1l'\"
else
echo shar: Extracting \"'btt/bibgrep.1l'\" \(858 characters\)
sed "s/^X//" >'btt/bibgrep.1l' <<'END_OF_FILE'
X.TH BIBGREP 1l LOCAL
X.SH NAME
Xbibgrep \- Extract entries from a BIBTeX database
X.sp
X.SH SYNOPSIS
X\fBbibgrep  \fI [-c] [-n] [-r] keyword <file>\fR
X.sp
X.SH DESCRIPTION
X.I bibgrep
Xallows the extraction of entries from a \fIBIBTeX\fR database by the given
Xkeyword.
XEntries in which this key word is found are displayed on <stdout> in the
Xformat that they appear in the database.
X.br
XThis can be used, for example, to extract all entries with a common subject
Xor author.
X.br
X.I bibgrep
Xnormally ignores the case of letters when performing comparisons.
XThe -c option causes upper and lower case letters to be differentiated.
XThe -r option reverses the find, i.e. all entries not matching the given
Xkeyword are selected.
XThe -n option causes bibgrep to output the count (number) of entries
Xrather than the entries themselves.
X.SH "SEE ALSO"
Xbibadd(1l), bibsort(1l)
END_OF_FILE
if test 858 -ne `wc -c <'btt/bibgrep.1l'`; then
    echo shar: \"'btt/bibgrep.1l'\" unpacked with wrong size!
fi
# end of 'btt/bibgrep.1l'
fi
if test -f 'btt/bibgrep.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'btt/bibgrep.c'\"
else
echo shar: Extracting \"'btt/bibgrep.c'\" \(3397 characters\)
sed "s/^X//" >'btt/bibgrep.c' <<'END_OF_FILE'
X/* bibgrep.c */
X
X#include <stdio.h>
X#ifdef SYSV
X#include <string.h>
X#define index strchr
X#endif
X#ifdef BSD
X#include <strings.h>
X#endif
X#include <ctype.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
XFILE * in;
X#define BUFLEN 4000
X#define STRLEN 500
X
Xextern char *getenv();
X
Xmain (argc, argv)
Xint argc;
Xchar * argv[];
X{
X	FILE * fopen();
X	char * key;
X	int caseop = 1, modeop=1, countonly=0, count=0;
X	int ret ,length, iseof, print, lnlen, keylen, i, j;
X	struct stat stbuf;
X	char buf[BUFLEN];
X	char filename[STRLEN];
X	char actstr[STRLEN];
X	char *texinputs, *top, *end;
X
X	argv++, argc--;
X	while ((argc > 0) && (argv[0][0] == '-')) {
X		if (argv[0][1] == 'r') modeop = 0;
X		else {
X			if (argv[0][1] == 'n') countonly=1;
X			else {
X				if (argv[0][1] == 'c') caseop=0;
X				else usageerr();
X			}
X		}
X		argv++, argc--;
X	}
X	if (argc <= 1) usageerr();
X	key = *argv;
X	keylen = strlen(key);
X	texinputs = getenv("TEXINPUTS");
X	while (--argc,++argv, argc>0 ) {
X		if ((texinputs != NULL) && (**argv != '/')) {
X			if (STRLEN <= (strlen(texinputs) + strlen(*argv)))
X			  fprintf(stderr, "Warning: Environment String too long\n");
X			strncpy(actstr,texinputs,STRLEN);
X			top = actstr;
X			end = actstr;
X			ret = -1;
X			while (end != NULL) { /* evaluate TEXINPUTS */
X				end = index(top,':'); /* Search for first : */
X				if (end != NULL) *end = '\0'; /* modify : to \0 */
X				strncpy(filename,top,STRLEN);
X				if (end != NULL) top = ++end;
X				if (!(length = strlen(filename))) continue;
X				filename[length++] = '/';
X				filename[length] = '\0';
X				strcat(filename,*argv);
X				if ((ret = stat(filename,&stbuf)) ==  0)  break;
X			}
X			if (ret < 0) {
X				fprintf(stderr,"file not found: %s\n",*argv);
X				continue;
X			}
X		}
X		else strcpy(filename,*argv); /* TEXINPUTS was not set or filename
X					begins with a / */
X
X		if (stat(filename,&stbuf) < 0) {
X			fprintf(stderr,"file not found: %s\n",filename);
X			continue;
X		}
X		if ((stbuf.st_mode & S_IFMT) != S_IFREG) {
X			fprintf(stderr," %s is not an ordinary file\n",filename);
X			continue;
X		}
X		if ((in=fopen(filename,"r")) == NULL) {
X			fprintf(stderr,"%s can not be opened\n",filename);
X			continue;
X		}
X		lnlen = 0;
X		while (1) {
X			iseof = getline(buf,&lnlen);
X			print=0;
X			for (i=j=0; i<(lnlen+j-keylen) ; i++)
X				if (key[j] == buf[i] || (caseop && (
X				(key[j] == (buf[i]+32) && isupper(buf[i])) ||
X				    (key[j] == (buf[i]-32) && isupper(key[j]))))) {
X					if (++j == keylen) {
X						print = 1;
X						break;
X					}
X				} else j=0;
X			if (print == modeop)
X			    if (countonly)
X				count++;
X			    else
X				for (i=0 ; i<lnlen ; i++) putchar(buf[i]);
X			if (iseof == EOF) break;
X		}
X	}
X	if (countonly) printf("%d\n", count);
X	exit(0);
X}
X
Xint getline(line,len)
Xchar * line;
Xint * len;
X{
X	int count = 0;
X	int startline = 0;
X
X	if ((*line = getc(in)) == EOF)
X		return(EOF);
X	else
X	    count++, line++;
X	while ((*line = getc(in)) != EOF) {
X		if (*line == '@' && startline) break;
X		if (*line == '\n')
X			startline = 1;
X		else
X			startline = 0;
X		count++;
X		line++;
X		if (count > BUFLEN) {
X			fprintf(stderr,"Entry too long\n");
X			exit(1);
X		}
X	}
X	*len = count;
X	if (*line == EOF)
X		return(EOF);
X	else
X		ungetc(*line, in);
X	return(count);
X}
X
Xusageerr()
X{
X	fprintf(stderr,"usage:bibgrep [-c][-n][-r] keyword <files>\n\t-c\tdon't ignore case\n\t-n\tcount entries matching rather than printing them\n\t-r\tselect entries that don't match keyword\n");
X	exit(1);
X}
END_OF_FILE
if test 3397 -ne `wc -c <'btt/bibgrep.c'`; then
    echo shar: \"'btt/bibgrep.c'\" unpacked with wrong size!
fi
# end of 'btt/bibgrep.c'
fi
if test -f 'btt/bibsort.1l' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'btt/bibsort.1l'\"
else
echo shar: Extracting \"'btt/bibsort.1l'\" \(769 characters\)
sed "s/^X//" >'btt/bibsort.1l' <<'END_OF_FILE'
X.TH BIBSORT 1l LOCAL
X.SH NAME
Xbibsort \- Sort a BIBTeX database
X.sp
X.SH SYNOPSIS
X\fBbibsort  \fR <file>
X.sp
X.SH DESCRIPTION
X.I bibsort
Xsorts the given database by the "cite" key field. If there are entries
Xwhich have conflicting "cite" keys,
X.I bibsort
Xappends a lower case letter to the "cite" key to differentiate them. For
Xexample, two Gnu:87 entries would become Gnu:87a and Gnu:87b. Should there
Xbe two conflicting entries which are annotated in the form described
Xabove,
X.I bibsort
Xwill modify later entries to resolve the conflict. For example, Gnu:87a and
XGnu:87a would become Gnu:87a and Gnu:87b. This means that older entries will
Xnot be modified when new entries are added.
X.br
XThe sorted database appears on <stdout>.
X.SH "SEE ALSO"
Xbibadd(1l), bibgrep(1l)
END_OF_FILE
if test 769 -ne `wc -c <'btt/bibsort.1l'`; then
    echo shar: \"'btt/bibsort.1l'\" unpacked with wrong size!
fi
# end of 'btt/bibsort.1l'
fi
if test -f 'btt/bibsort.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'btt/bibsort.c'\"
else
echo shar: Extracting \"'btt/bibsort.c'\" \(4196 characters\)
sed "s/^X//" >'btt/bibsort.c' <<'END_OF_FILE'
X/* bibsort.c */
X
X#include <stdio.h>
X#include <sys/types.h>
X#ifdef SYSV
X#include <string.h>
X#endif
X#ifdef BSD
X#include <strings.h>
X#endif 
X#include <sys/stat.h>
X#include <ctype.h>
X
X#define MAXENT 4000
X#define BUFLEN 4000
X#define TYPELEN 18
X#define CITELEN 30
XFILE *in;
Xchar *prog;
X
Xmain (argc, argv)
Xint argc;
Xchar * argv[];
X{
X    FILE * fopen();
X    char * cite;
X    int iseof, blen, i, j, item;
X    struct stat stbuf;
X    struct bibitem {
X	char type[TYPELEN];
X	char cite[CITELEN];
X	char ident;
X	char *info;
X	struct bibitem *next, *prev;
X    } biblist[MAXENT];
X    struct bibitem *akt, *pt, *start;
X    char buf[BUFLEN];
X
X    prog=*argv;
X    argv++, argc--;
X    if (!argc) {
X	fprintf(stderr,"usage:%s <files>\n", prog);
X	exit(1);
X    }
X    item = 0;
X    start = akt = biblist;
X    for (; argc>0 ; --argc, ++argv ) {
X	if (stat(*argv,&stbuf) < 0) {
X	    fprintf(stderr,"%s: %s in wrong state\n",prog, *argv);
X	    continue;
X	}
X	if ((stbuf.st_mode & S_IFMT) != S_IFREG) {
X	    fprintf(stderr,"%s: %s not reg. file\n",prog, *argv);
X	    continue;
X	}
X	if ((in=fopen(*argv,"r")) == NULL) {
X	    fprintf(stderr,"%s: can't open %s\n",prog, *argv);
X	    continue;
X	}
X	while ((*buf = getc(in)) != EOF && *buf != '@')
X	    ;
X	if (*buf == EOF)
X	    continue;
X	for ( ; item < MAXENT ; item++) {
X	    iseof = getentry(buf,&blen);
X	    i = 1;
X	    biblist[item].type[0] = '@';
X	    for (; isalpha(buf[i]) && i < TYPELEN ; i++)
X		biblist[item].type[i] = buf[i];
X	    if (i >= TYPELEN-1)
X		fprintf(stderr, "%s: type overflow at %s\n", prog,buf), exit(1);
X	    biblist[item].type[i] = '\0';
X	    if (!strcmp("@STRING",biblist[item].type) ||
X		!strcmp("@PREAMBLE",biblist[item].type) ||
X		!strcmp("@string",biblist[item].type) ||
X		!strcmp("@preamble",biblist[item].type)) {
X		printf("%s",buf);
X		item--;
X		if (iseof == EOF) break;
X		else continue;
X	    }
X	    biblist[item].type[i] = buf[i];
X	    i++;
X	    biblist[item].type[i] = '\0';
X	    for (j=0 ; buf[i] != ',' && j < CITELEN ; i++, j++)
X		biblist[item].cite[j] = buf[i];
X	    if (j == CITELEN)
X		fprintf(stderr, "%s: cite overflow at %s\n",prog, buf), exit(1);
X	    if (isalpha(buf[i-1])) {
X		biblist[item].cite[j-1] = '\0';
X		biblist[item].ident = buf[i-1];
X	    }
X	    else {
X		biblist[item].ident = 0;
X		biblist[item].cite[j] = '\0';
X	    }
X	    biblist[item].info = (char *)malloc(blen-i+1);
X	    for (j=0 ; i < blen ; i++, j++)
X		biblist[item].info[j] = buf[i];
X	    if (item == 0) {
X		biblist[item].next = 0;
X		biblist[item].prev = 0;
X		if (iseof == EOF) break;
X		else continue;
X	    }
X	    if ((j = strcmp(akt->cite, biblist[item].cite)) <= 0) {
X		if (j == 0) {
X		    if (akt->ident == 0)
X			akt->ident = 'a';
X			biblist[item].ident = akt->ident + 1;
X		}
X		biblist[item].next = 0;
X		biblist[item].prev = akt;
X		akt->next = &biblist[item];
X		akt = &biblist[item];
X	    }
X	    else {
X		for (pt = akt->prev ; pt != 0 && (j = strcmp(pt->cite,
X		     biblist[item].cite)) > 0 ;pt = pt->prev) ;
X		if (j == 0) {
X		    if (pt->ident == 0)
X			pt->ident = 'a';
X		    biblist[item].ident = pt->ident + 1;
X		}
X		if (pt == 0) {
X		    biblist[item].next = start;
X		    start->prev = &biblist[item];
X		    start = &biblist[item];
X		    biblist[item].prev = 0;
X		}
X		else {
X		    biblist[item].next = pt->next;
X		    pt->next = &biblist[item];
X		    biblist[item].prev = pt;
X		    biblist[item].next->prev = &biblist[item];
X		}
X	    }
X	    if (iseof == EOF)
X		break;
X	}
X	if (item++ >= MAXENT) {
X	    fprintf(stderr, "%s: too many entries\n", prog);
X	    break;
X	}
X	fclose(in);
X    }
X    if (item != 0)
X      for (pt = start ; pt != 0 ; pt = pt->next) {
X	printf("%s%s",pt->type,pt->cite);
X	if (pt->ident)
X	    putchar(pt->ident);
X	printf("%s",pt->info);
X      }
X    exit(0);
X}
X
Xint getentry(line,len)
Xchar * line;
Xint * len;
X{
X	int count = 2;
X	int startline = 0;
X	char *st;
X
X	st = line;
X	*line++ = '@';
X	while ((*line = getc(in)) != EOF) {
X		if (*line == '@' && startline) break;
X		if (*line == '\n')
X			startline = 1;
X		else
X			startline = 0;
X		if (++count >= BUFLEN) {
X		    fprintf(stderr, "%s: buffer overflow at %s\n", prog,st);
X		    break;
X		}
X		line++;
X	}
X	*len = count;
X	if (*line == EOF) {
X		*line = '\0';
X		return(EOF);
X	}
X	*line = '\0';
X	return(count);
X}
END_OF_FILE
if test 4196 -ne `wc -c <'btt/bibsort.c'`; then
    echo shar: \"'btt/bibsort.c'\" unpacked with wrong size!
fi
# end of 'btt/bibsort.c'
fi
if test -f 'btt/btt' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'btt/btt'\"
else
echo shar: Extracting \"'btt/btt'\" \(5921 characters\)
sed "s/^X//" >'btt/btt' <<'END_OF_FILE'
X#! /bin/sh
X# thanks to the following people for making suggestions/comments about btt:
X#	Mark Korsloot	(mark@cs.uoregon.edu)
X#
X# you may need to change the line below to allow access to things like grep etc.
XPATH=/usr/local/bin:/bin:/usr/bin:/usr/ucb:/homes/stg/otcbin:/usr/local/tex:/homes/stg/bin
Xt1=/tmp/btt1$$
Xt2=/tmp/btt2$$
XBIBTEX=/usr/local/bibtex
XTEXEDIT=${TEXEDIT:-$VISUAL}
XTEXEDIT=${TEXEDIT:-$EDITOR}
XTEXEDIT=${TEXEDIT:-vi}
Xcase $TEXEDIT in
X*vi) TEXEDIT="$TEXEDIT +\$"
Xesac
Xtrap '/bin/rm -f $t1 $t2; exit' 0 1 2 15
Xprog=`basename $0`
Xif [ $# = 0 ]
Xthen
X        echo "usage: $prog filename"
X        exit 1
Xfi
X
Xcase $1 in
X*.bib)	file=$1
X	base=`echo $1 | sed 's/\.bib$//'`;;
X*)	base=$1
X	if [ ! -f $base.bib -a -f $base ]
X	then
X		file=$base
X	else
X		file=$base.bib
X	fi
Xesac
X
Xbttpr="`basename $base`#P"
X# Check file is there.
Xif [ ! -f $file ]
Xthen
X    echo "$prog: $file not found"
X    /bin/echo -n "Create New BiBTeX database (y/n)? "
X    read response
X    if [ $response = "y" -o $response = "Y" ]
X    then
X	/bin/echo -n > $file
X    else
X	exit 1
X    fi
Xfi
Xif [ ! -r $file ]
Xthen
X	echo "Warning: $file not readable"
Xfi
Xif [ ! -w $file ]
Xthen
X	echo "Warning: $file not writeable"
Xfi
Xecho "$prog: ? for help"
Xwhile :
Xdo
X   /bin/echo -n "
X$prog options: Add,Edit,Find,Info,List,Print,Quit,Sort ?"
X   read response
X   if [ "$response" = "" ]
X   then
X	continue
X   fi
X   case $response in
X   a|A|add|Add|ADD)
X	bibadd $file;;
X   e|E|edit|Edit|EDIT)
X	/bin/cp $file $file.bak
X	$TEXEDIT $file;;
X   f|F|find|Find|FIND) 
X#	Get keywords
X	/bin/echo -n "Enter words which must appear in the bibtex entry (space seperated).
XUse !word to reverse search for a particular word, e.g. "word1 !word2 word3"
Xwill search for entries containing word1 and word3 but not word2.
X
Xsearch words ?"
X	read response
X#	Remove strings
X	bibgrep -r @string $file > $t1
X	echo
X#	Process each keyword
X	for WORD in $response
X	do
X		/bin/echo -n "searching for: $WORD"
X		case $WORD in
X		!*) NOT="-r"; WORD=`echo $WORD | sed 's/!//'`;;
X		*) NOT=""
X		esac
X		bibgrep $NOT $WORD $t1 > $t2
X		echo "	cummulative matches: `egrep -c '^@' $t2`"
X		/bin/mv $t2 $t1
X        done
X	echo
X	more $t1;;
X   h|H|help|Help|HELP|\?)
X	echo "
X$prog options:
X
X	Add	add bib entries or strings to database
X	Find	search for bib entries
X	Info	gives number of bibtex entries and string abbreviations, etc
X	List	list entries, strings, keys, style macros
X	Print	print hard copy of bibliography
X	Quit	quit $prog
X	Sort	sort bib entries
X
XSelect one of the options by typing its first letter and pressing return";;
X   i|I|info|Info|INFO)
X	echo "
Xfile:     $file    	(`/bin/ls -l $file|awk '{printf \"%s %s %s, %s chars\",$5,$6,$7,$4}'`)"
X	if [ -f $file.bak ]
X	then
X		echo "backup:   $file.bak	(`/bin/ls -l $file.bak | awk '{ printf \"%s %s %s, %s chars\",$5,$6,$7,$4}'`)"
X	else
X		echo "backup:   $file.bak	(not found)"
X	fi
X	bibgrep -r @string $file > $t1
X	/bin/echo -n "entries:  "
X	/bin/echo -n "`egrep -c '^@' $t1`"
X	echo "		(duplicate keys: `sed -n '/^@.*{.*,[	]*$/s/^@.*{\(.*\)[ 	]*,[ 	]*$/\1/p' $t1|sort -d |uniq -d|wc -l|sed 's/\ //g'`)"
X	sed -n '/^@[sS][tT][rR][iI][nN][gG]{/s/^@.*[gG]{\(.*\)[ 	]*=.*$/\1/p' $file > $t1
X	/bin/echo -n "strings:  `wc -l $t1|awk '{ print $1 }'"
X	echo "		(duplicate keys: `sort -d $t1|uniq -d|wc -l|sed 's/\ //g'`)"
X	echo "`wc -lw $file | awk '{printf \"lines:    %s\nwords:    %s\",$1,$2}'`"
X	;;
X   l|L|less|list|List|LIST)
X	/bin/echo -n "list options: All,Entries,Strings,Keys,Macros ?"
X	read response
X	if [ "$response" = "" ]
X	then
X		continue
X	fi
X	case $response in
X	a*|A*)
X		less $file;;
X	e*|E*)
X		bibgrep -r @string $file | less;;
X	s*|S*)
X		bibgrep @string $file | less;;
X	m*|M*)
X		/bin/echo -n "Name of BibTex style (e.g., plain) ?"
X		read name
X		for x in `echo $TEXINPUTS | sed -e 's/:/ /g'`
X		do
X			if [ -f $x/$name.bst ]
X			then
X				grep MACRO $x/$name.bst |
X				 sed -e 's/MACRO\ [{]\([^}]*\)[}]/\1 =/' -e 's/[{]\"/{/' -e 's/\"[}]/}/' |
X				 less
X				break
X			fi
X		done;;
X	k*|K*)
X#		Remove strings
X		bibgrep -r @string $file |
X#		Expand and remove trailing spaces
X		sed 's/ *$//' |
X#		Get key names
X#		sed -n '/^@.*{.*,$/s/^@.*{\(.*\),$/\1/p' |
X		sed -n '/^@.*{.*$/s/^@.*{\(.*[^,]\),*$/\1/p' |
X#		Sort alphabetically, count and view
X		sort -d | uniq -c | less;;
X	q*|Q*);;
X	*)
X		echo "Invalid Option";;
X	esac;;
X   p|P|Print|print|PRINT)
X	if [ -f $bttpr.tex ]
X	then
X		echo "Print file: $bttpr"
X	else
X		echo "Creating print file: $bttpr"
X#		you may wish to have some additional macros in the echo line:
X#		e.g. echo "\\documentstyle[a4large,tabverb,printbib]{article}
X#			tabverb is a style for inputting files verbatim (among
X#			other things), a4large is a style for making use of
X#			most of the page.  You may also want to change the
X#			font size by including 11pt or 12pt as an option.
X#		you may want to include the following two lines (assuming you
X#		have tabverb.sty loaded) just before the \\end{document} line.
X#			\\centerline{\\bf Bibtex Report}
X#			\\inputverbatim{$bttpr.blg}
X		echo "\\documentstyle[printbib]{article}
X\\textheight 750pt
X\\textwidth 485pt
X\\begin{document}
X\\nocite{*}
X\\centerline{\\bf References in `echo $file | sed 's/\_/\\\_/g'` -- \\today}
X\\bibliography{$base}
X\\bibliographystyle{cite}
X\\end{document}
X" > $bttpr.tex
X	fi
X	if [ ! -f $bttpr.aux ]
X	then
X		echo "\\relax
X\\citation{*}
X\\bibdata{$base}
X\\bibstyle{cite}
X" > $bttpr.aux
X	fi
X	$BIBTEX $bttpr
X	latex $bttpr
X#	required for crossrefs etc
X#	latex $bttpr
X#	put your favourite dvi printing program/commands here
X	dvipr $bttpr
X#	/bin/rm -f $bttpr.plg $bttpr.bbl $bttpr.dvi $bttpr.blg $btt.log
X	;;
X   q|Q|quit|Quit|QUIT)
X	exit 0;;
X   s|S|sort|Sort|SORT)
X	/bin/echo -n "sorting ... "
X#	remove trailing spaces
X	sed 's/ *$//' $file > $file.bak
X#	Now sort it and place back in original file
X	bibsort $file.bak > $file
X	echo "done"
X	;;
X   !*)
X	response=`echo $response | sed 's/^!//'`
X	$response
X	;;
X   *) echo "invalid option, try again (? for help)"
X   esac
Xdone
END_OF_FILE
if test 5921 -ne `wc -c <'btt/btt'`; then
    echo shar: \"'btt/btt'\" unpacked with wrong size!
fi
chmod +x 'btt/btt'
# end of 'btt/btt'
fi
if test -f 'btt/cite.bst' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'btt/cite.bst'\"
else
echo shar: Extracting \"'btt/cite.bst'\" \(21396 characters\)
sed "s/^X//" >'btt/cite.bst' <<'END_OF_FILE'
X% BibTeX non-standard bibliography style `cite'
X% modified from standard bibliography style `alpha'
X% changed to print citekey as label
X	% version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09.
X	% Copyright (C) 1985, all rights reserved.
X	% Copying of this file is authorized only if either
X	% (1) you make absolutely no changes to your copy, including name, or
X	% (2) if you do make changes, you name it something other than
X	% btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
X	% This restriction helps ensure that all standard styles are identical.
X	% The file btxbst.doc has the documentation for this style.
X
XENTRY
X  { address
X    annote
X    author
X    booktitle
X    chapter
X    edition
X    editor
X    howpublished
X    institution
X    journal
X    key
X    month
X    note
X    number
X    organization
X    pages
X    publisher
X    school
X    series
X    title
X    type
X    volume
X    year
X  }
X  {}
X  { label extra.label sort.label }
X
XINTEGERS { output.state before.all mid.sentence after.sentence after.block }
X
XFUNCTION {init.state.consts}
X{ #0 'before.all :=
X  #1 'mid.sentence :=
X  #2 'after.sentence :=
X  #3 'after.block :=
X}
X
XSTRINGS { s t }
X
XFUNCTION {output.nonnull}
X{ 's :=
X  output.state mid.sentence =
X    { ", " * write$ }
X    { output.state after.block =
X	{ add.period$ write$
X	  newline$
X	  "\newblock " write$
X	}
X	{ output.state before.all =
X	    'write$
X	    { add.period$ " " * write$ }
X	  if$
X	}
X      if$
X      mid.sentence 'output.state :=
X    }
X  if$
X  s
X}
X
XFUNCTION {output}
X{ duplicate$ empty$
X    'pop$
X    'output.nonnull
X  if$
X}
X
XFUNCTION {output.check}
X{ 't :=
X  duplicate$ empty$
X    { pop$ "empty " t * " in " * cite$ * warning$ }
X    'output.nonnull
X  if$
X}
X
XFUNCTION {output.bibitem}
X{ newline$
X  "\bibitem[" write$
X  label write$
X  "]{" write$
X  cite$ write$
X  "}" write$
X  newline$
X  ""
X  before.all 'output.state :=
X}
X
XFUNCTION {fin.entry}
X{ add.period$
X  write$
X  newline$
X}
X
XFUNCTION {new.block}
X{ output.state before.all =
X    'skip$
X    { after.block 'output.state := }
X  if$
X}
X
XFUNCTION {new.sentence}
X{ output.state after.block =
X    'skip$
X    { output.state before.all =
X	'skip$
X	{ after.sentence 'output.state := }
X      if$
X    }
X  if$
X}
X
XFUNCTION {not}
X{   { #0 }
X    { #1 }
X  if$
X}
X
XFUNCTION {and}
X{   'skip$
X    { pop$ #0 }
X  if$
X}
X
XFUNCTION {or}
X{   { pop$ #1 }
X    'skip$
X  if$
X}
X
XFUNCTION {new.block.checka}
X{ empty$
X    'skip$
X    'new.block
X  if$
X}
X
XFUNCTION {new.block.checkb}
X{ empty$
X  swap$ empty$
X  and
X    'skip$
X    'new.block
X  if$
X}
X
XFUNCTION {new.sentence.checka}
X{ empty$
X    'skip$
X    'new.sentence
X  if$
X}
X
XFUNCTION {new.sentence.checkb}
X{ empty$
X  swap$ empty$
X  and
X    'skip$
X    'new.sentence
X  if$
X}
X
XFUNCTION {field.or.null}
X{ duplicate$ empty$
X    { pop$ "" }
X    'skip$
X  if$
X}
X
XFUNCTION {emphasize}
X{ duplicate$ empty$
X    { pop$ "" }
X    { "{\em " swap$ * "}" * }
X  if$
X}
X
XINTEGERS { nameptr namesleft numnames }
X
XFUNCTION {format.names}
X{ 's :=
X  #1 'nameptr :=
X  s num.names$ 'numnames :=
X  numnames 'namesleft :=
X    { namesleft #0 > }
X    { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
X      nameptr #1 >
X	{ namesleft #1 >
X	    { ", " * t * }
X	    { numnames #2 >
X		{ "," * }
X		'skip$
X	      if$
X	      t "others" =
X		{ " et~al." * }
X		{ " and " * t * }
X	      if$
X	    }
X	  if$
X	}
X	't
X      if$
X      nameptr #1 + 'nameptr :=
X      namesleft #1 - 'namesleft :=
X    }
X  while$
X}
X
XFUNCTION {format.authors}
X{ author empty$
X    { "" }
X    { author format.names }
X  if$
X}
X
XFUNCTION {format.editors}
X{ editor empty$
X    { "" }
X    { editor format.names
X      editor num.names$ #1 >
X	{ ", editors" * }
X	{ ", editor" * }
X      if$
X    }
X  if$
X}
X
XFUNCTION {format.title}
X{ title empty$
X    { "" }
X    { title "t" change.case$ }
X  if$
X}
X
XFUNCTION {n.dashify}
X{ 't :=
X  ""
X    { t empty$ not }
X    { t #1 #1 substring$ "-" =
X	{ t #1 #2 substring$ "--" = not
X	    { "--" *
X	      t #2 global.max$ substring$ 't :=
X	    }
X	    {   { t #1 #1 substring$ "-" = }
X		{ "-" *
X		  t #2 global.max$ substring$ 't :=
X		}
X	      while$
X	    }
X	  if$
X	}
X	{ t #1 #1 substring$ *
X	  t #2 global.max$ substring$ 't :=
X	}
X      if$
X    }
X  while$
X}
X
XFUNCTION {format.date}
X{ year empty$
X    { month empty$
X	{ "" }
X	{ "there's a month but no year in " cite$ * warning$
X	  month
X	}
X      if$
X    }
X    { month empty$
X	'year
X	{ month " " * year * }
X      if$
X    }
X  if$
X}
X
XFUNCTION {format.btitle}
X{ title emphasize
X}
X
XFUNCTION {tie.or.space.connect}
X{ duplicate$ text.length$ #3 <
X    { "~" }
X    { " " }
X  if$
X  swap$ * *
X}
X
XFUNCTION {either.or.check}
X{ empty$
X    'pop$
X    { "can't use both " swap$ * " fields in " * cite$ * warning$ }
X  if$
X}
X
XFUNCTION {format.bvolume}
X{ volume empty$
X    { "" }
X    { "volume" volume tie.or.space.connect
X      series empty$
X	'skip$
X	{ " of " * series emphasize * }
X      if$
X      "volume and number" number either.or.check
X    }
X  if$
X}
X
XFUNCTION {format.number.series}
X{ volume empty$
X    { number empty$
X	{ series field.or.null }
X	{ output.state mid.sentence =
X	    { "number" }
X	    { "Number" }
X	  if$
X	  number tie.or.space.connect
X	  series empty$
X	    { "there's a number but no series in " cite$ * warning$ }
X	    { " in " * series * }
X	  if$
X	}
X      if$
X    }
X    { "" }
X  if$
X}
X
XFUNCTION {format.edition}
X{ edition empty$
X    { "" }
X    { output.state mid.sentence =
X	{ edition "l" change.case$ " edition" * }
X	{ edition "t" change.case$ " edition" * }
X      if$
X    }
X  if$
X}
X
XINTEGERS { multiresult }
X
XFUNCTION {multi.page.check}
X{ 't :=
X  #0 'multiresult :=
X    { multiresult not
X      t empty$ not
X      and
X    }
X    { t #1 #1 substring$
X      duplicate$ "-" =
X      swap$ duplicate$ "," =
X      swap$ "+" =
X      or or
X	{ #1 'multiresult := }
X	{ t #2 global.max$ substring$ 't := }
X      if$
X    }
X  while$
X  multiresult
X}
X
XFUNCTION {format.pages}
X{ pages empty$
X    { "" }
X    { pages multi.page.check
X	{ "pages" pages n.dashify tie.or.space.connect }
X	{ "page" pages tie.or.space.connect }
X      if$
X    }
X  if$
X}
X
XFUNCTION {format.vol.num.pages}
X{ volume field.or.null
X  number empty$
X    'skip$
X    { "(" number * ")" * *
X      volume empty$
X	{ "there's a number but no volume in " cite$ * warning$ }
X	'skip$
X      if$
X    }
X  if$
X  pages empty$
X    'skip$
X    { duplicate$ empty$
X	{ pop$ format.pages }
X	{ ":" * pages n.dashify * }
X      if$
X    }
X  if$
X}
X
XFUNCTION {format.chapter.pages}
X{ chapter empty$
X    'format.pages
X    { type empty$
X	{ "chapter" }
X	{ type "l" change.case$ }
X      if$
X      chapter tie.or.space.connect
X      pages empty$
X	'skip$
X	{ ", " * format.pages * }
X      if$
X    }
X  if$
X}
X
XFUNCTION {format.in.ed.booktitle}
X{ booktitle empty$
X    { "" }
X    { editor empty$
X	{ "In " booktitle emphasize * }
X	{ "In " format.editors * ", " * booktitle emphasize * }
X      if$
X    }
X  if$
X}
X
XFUNCTION {empty.misc.check}
X{ author empty$ title empty$ howpublished empty$
X  month empty$ year empty$ note empty$
X  and and and and and
X  key empty$ not and
X    { "all relevant fields are empty in " cite$ * warning$ }
X    'skip$
X  if$
X}
X
XFUNCTION {format.thesis.type}
X{ type empty$
X    'skip$
X    { pop$
X      type "t" change.case$
X    }
X  if$
X}
X
XFUNCTION {format.tr.number}
X{ type empty$
X    { "Technical Report" }
X    'type
X  if$
X  number empty$
X    { "t" change.case$ }
X    { number tie.or.space.connect }
X  if$
X}
X
XFUNCTION {format.article.crossref}
X{ key empty$
X    { journal empty$
X	{ "need key or journal for " cite$ * " to crossref " * crossref *
X	  warning$
X	  ""
X	}
X	{ "In {\em " journal * "\/}" * }
X      if$
X    }
X    { "In " key * }
X  if$
X  " \cite{" * crossref * "}" *
X}
X
XFUNCTION {format.crossref.editor}
X{ editor #1 "{vv~}{ll}" format.name$
X  editor num.names$ duplicate$
X  #2 >
X    { pop$ " et~al." * }
X    { #2 <
X	'skip$
X	{ editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
X	    { " et~al." * }
X	    { " and " * editor #2 "{vv~}{ll}" format.name$ * }
X	  if$
X	}
X      if$
X    }
X  if$
X}
X
XFUNCTION {format.book.crossref}
X{ volume empty$
X    { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
X      "In "
X    }
X    { "Volume" volume tie.or.space.connect
X      " of " *
X    }
X  if$
X  editor empty$
X  editor field.or.null author field.or.null =
X  or
X    { key empty$
X	{ series empty$
X	    { "need editor, key, or series for " cite$ * " to crossref " *
X	      crossref * warning$
X	      "" *
X	    }
X	    { "{\em " * series * "\/}" * }
X	  if$
X	}
X	{ key * }
X      if$
X    }
X    { format.crossref.editor * }
X  if$
X  " \cite{" * crossref * "}" *
X}
X
XFUNCTION {format.incoll.inproc.crossref}
X{ editor empty$
X  editor field.or.null author field.or.null =
X  or
X    { key empty$
X	{ booktitle empty$
X	    { "need editor, key, or booktitle for " cite$ * " to crossref " *
X	      crossref * warning$
X	      ""
X	    }
X	    { "In {\em " booktitle * "\/}" * }
X	  if$
X	}
X	{ "In " key * }
X      if$
X    }
X    { "In " format.crossref.editor * }
X  if$
X  " \cite{" * crossref * "}" *
X}
X
XFUNCTION {do.annote}
X{ add.period$
X  write$
X  newline$
X  annote missing$
X    { skip$ }
X    { newline$
X      "{\sl{}" write$
X      annote write$
X      "}" write$
X    }
X  if$
X  ""
X}
X
XFUNCTION {article}
X{ output.bibitem
X  format.authors "author" output.check
X  new.block
X  format.title "title" output.check
X  new.block
X  crossref missing$
X    { journal emphasize "journal" output.check
X      format.vol.num.pages output
X      format.date "year" output.check
X    }
X    { format.article.crossref output.nonnull
X      format.pages output
X    }
X  if$
X  new.block
X  note output
X  do.annote
X  fin.entry
X}
X
XFUNCTION {book}
X{ output.bibitem
X  author empty$
X    { format.editors "author and editor" output.check }
X    { format.authors output.nonnull
X      crossref missing$
X	{ "author and editor" editor either.or.check }
X	'skip$
X      if$
X    }
X  if$
X  new.block
X  format.btitle "title" output.check
X  crossref missing$
X    { format.bvolume output
X      new.block
X      format.number.series output
X      new.sentence
X      publisher "publisher" output.check
X      address output
X    }
X    { new.block
X      format.book.crossref output.nonnull
X    }
X  if$
X  format.edition output
X  format.date "year" output.check
X  new.block
X  note output
X  do.annote
X  fin.entry
X}
X
XFUNCTION {booklet}
X{ output.bibitem
X  format.authors output
X  new.block
X  format.title "title" output.check
X  howpublished address new.block.checkb
X  howpublished output
X  address output
X  format.date output
X  new.block
X  note output
X  do.annote
X  fin.entry
X}
X
XFUNCTION {inbook}
X{ output.bibitem
X  author empty$
X    { format.editors "author and editor" output.check }
X    { format.authors output.nonnull
X      crossref missing$
X	{ "author and editor" editor either.or.check }
X	'skip$
X      if$
X    }
X  if$
X  new.block
X  format.btitle "title" output.check
X  crossref missing$
X    { format.bvolume output
X      format.chapter.pages "chapter and pages" output.check
X      new.block
X      format.number.series output
X      new.sentence
X      publisher "publisher" output.check
X      address output
X    }
X    { format.chapter.pages "chapter and pages" output.check
X      new.block
X      format.book.crossref output.nonnull
X    }
X  if$
X  format.edition output
X  format.date "year" output.check
X  new.block
X  note output
X  do.annote
X  fin.entry
X}
X
XFUNCTION {incollection}
X{ output.bibitem
X  format.authors "author" output.check
X  new.block
X  format.title "title" output.check
X  new.block
X  crossref missing$
X    { format.in.ed.booktitle "booktitle" output.check
X      format.bvolume output
X      format.number.series output
X      format.chapter.pages output
X      new.sentence
X      publisher "publisher" output.check
X      address output
X      format.edition output
X      format.date "year" output.check
X    }
X    { format.incoll.inproc.crossref output.nonnull
X      format.chapter.pages output
X    }
X  if$
X  new.block
X  note output
X  do.annote
X  fin.entry
X}
X
XFUNCTION {inproceedings}
X{ output.bibitem
X  format.authors "author" output.check
X  new.block
X  format.title "title" output.check
X  new.block
X  crossref missing$
X    { format.in.ed.booktitle "booktitle" output.check
X      format.bvolume output
X      format.number.series output
X      format.pages output
X      address empty$
X	{ organization publisher new.sentence.checkb
X	  organization output
X	  publisher output
X	  format.date "year" output.check
X	}
X	{ address output.nonnull
X	  format.date "year" output.check
X	  new.sentence
X	  organization output
X	  publisher output
X	}
X      if$
X    }
X    { format.incoll.inproc.crossref output.nonnull
X      format.pages output
X    }
X  if$
X  new.block
X  note output
X  do.annote
X  fin.entry
X}
X
XFUNCTION {conference} { inproceedings }
X
XFUNCTION {manual}
X{ output.bibitem
X  author empty$
X    { organization empty$
X	'skip$
X	{ organization output.nonnull
X	  address output
X	}
X      if$
X    }
X    { format.authors output.nonnull }
X  if$
X  new.block
X  format.btitle "title" output.check
X  author empty$
X    { organization empty$
X	{ address new.block.checka
X	  address output
X	}
X	'skip$
X      if$
X    }
X    { organization address new.block.checkb
X      organization output
X      address output
X    }
X  if$
X  format.edition output
X  format.date output
X  new.block
X  note output
X  do.annote
X  fin.entry
X}
X
XFUNCTION {mastersthesis}
X{ output.bibitem
X  format.authors "author" output.check
X  new.block
X  format.title "title" output.check
X  new.block
X  "Master's thesis" format.thesis.type output.nonnull
X  school "school" output.check
X  address output
X  format.date "year" output.check
X  new.block
X  note output
X  do.annote
X  fin.entry
X}
X
XFUNCTION {misc}
X{ output.bibitem
X  format.authors output
X  title howpublished new.block.checkb
X  format.title output
X  howpublished new.block.checka
X  howpublished output
X  format.date output
X  new.block
X  note output
X  do.annote
X  fin.entry
X  empty.misc.check
X}
X
XFUNCTION {phdthesis}
X{ output.bibitem
X  format.authors "author" output.check
X  new.block
X  format.btitle "title" output.check
X  new.block
X  "PhD thesis" format.thesis.type output.nonnull
X  school "school" output.check
X  address output
X  format.date "year" output.check
X  new.block
X  note output
X  do.annote
X  fin.entry
X}
X
XFUNCTION {proceedings}
X{ output.bibitem
X  editor empty$
X    { organization output }
X    { format.editors output.nonnull }
X  if$
X  new.block
X  format.btitle "title" output.check
X  format.bvolume output
X  format.number.series output
X  address empty$
X    { editor empty$
X	{ publisher new.sentence.checka }
X	{ organization publisher new.sentence.checkb
X	  organization output
X	}
X      if$
X      publisher output
X      format.date "year" output.check
X    }
X    { address output.nonnull
X      format.date "year" output.check
X      new.sentence
X      editor empty$
X	'skip$
X	{ organization output }
X      if$
X      publisher output
X    }
X  if$
X  new.block
X  note output
X  do.annote
X  fin.entry
X}
X
XFUNCTION {techreport}
X{ output.bibitem
X  format.authors "author" output.check
X  new.block
X  format.title "title" output.check
X  new.block
X  format.tr.number output.nonnull
X  institution "institution" output.check
X  address output
X  format.date "year" output.check
X  new.block
X  note output
X  do.annote
X  fin.entry
X}
X
XFUNCTION {unpublished}
X{ output.bibitem
X  format.authors "author" output.check
X  new.block
X  format.title "title" output.check
X  new.block
X  note "note" output.check
X  format.date output
X  fin.entry
X}
X
XFUNCTION {default.type} { misc }
X
XMACRO {jan} {"January"}
X
XMACRO {feb} {"February"}
X
XMACRO {mar} {"March"}
X
XMACRO {apr} {"April"}
X
XMACRO {may} {"May"}
X
XMACRO {jun} {"June"}
X
XMACRO {jul} {"July"}
X
XMACRO {aug} {"August"}
X
XMACRO {sep} {"September"}
X
XMACRO {oct} {"October"}
X
XMACRO {nov} {"November"}
X
XMACRO {dec} {"December"}
X
XMACRO {acmcs} {"ACM Computing Surveys"}
X
XMACRO {acta} {"Acta Informatica"}
X
XMACRO {cacm} {"Communications of the ACM"}
X
XMACRO {ibmjrd} {"IBM Journal of Research and Development"}
X
XMACRO {ibmsj} {"IBM Systems Journal"}
X
XMACRO {ieeese} {"IEEE Transactions on Software Engineering"}
X
XMACRO {ieeetc} {"IEEE Transactions on Computers"}
X
XMACRO {ieeetcad}
X {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
X
XMACRO {ipl} {"Information Processing Letters"}
X
XMACRO {jacm} {"Journal of the ACM"}
X
XMACRO {jcss} {"Journal of Computer and System Sciences"}
X
XMACRO {scp} {"Science of Computer Programming"}
X
XMACRO {sicomp} {"SIAM Journal on Computing"}
X
XMACRO {tocs} {"ACM Transactions on Computer Systems"}
X
XMACRO {tods} {"ACM Transactions on Database Systems"}
X
XMACRO {tog} {"ACM Transactions on Graphics"}
X
XMACRO {toms} {"ACM Transactions on Mathematical Software"}
X
XMACRO {toois} {"ACM Transactions on Office Information Systems"}
X
XMACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
X
XMACRO {tcs} {"Theoretical Computer Science"}
X
XREAD
X
XFUNCTION {sortify}
X{ purify$
X  "l" change.case$
X}
X
XINTEGERS { len }
X
XFUNCTION {chop.word}
X{ 's :=
X  'len :=
X  s #1 len substring$ =
X    { s len #1 + global.max$ substring$ }
X    's
X  if$
X}
X
XINTEGERS { et.al.char.used }
X
XFUNCTION {initialize.et.al.char.used}
X{ #0 'et.al.char.used :=
X}
X
XEXECUTE {initialize.et.al.char.used}
X
XFUNCTION {format.lab.names}
X{ 's :=
X  s num.names$ 'numnames :=
X  numnames #1 >
X    { numnames #4 >
X	{ #3 'namesleft := }
X	{ numnames 'namesleft := }
X      if$
X      #1 'nameptr :=
X      ""
X	{ namesleft #0 > }
X	{ nameptr numnames =
X	    { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" =
X		{ "{\etalchar{+}}" *
X		  #1 'et.al.char.used :=
X		}
X		{ s nameptr "{v{}}{l{}}" format.name$ * }
X	      if$
X	    }
X	    { s nameptr "{v{}}{l{}}" format.name$ * }
X	  if$
X	  nameptr #1 + 'nameptr :=
X	  namesleft #1 - 'namesleft :=
X	}
X      while$
X      numnames #4 >
X	{ "{\etalchar{+}}" *
X	  #1 'et.al.char.used :=
X	}
X	'skip$
X      if$
X    }
X    { s #1 "{v{}}{l{}}" format.name$
X      duplicate$ text.length$ #2 <
X        { pop$ s #1 "{ll}" format.name$ duplicate$ text.length$ #5 <
X	     { #4 text.prefix$ }
X	     { #3 text.prefix$ }
X          if$
X        }
X	'skip$
X      if$
X    }
X  if$
X}
X
XFUNCTION {calc.label}
X{ cite$
X  sortify 'sort.label :=
X}
X
XFUNCTION {sort.format.names}
X{ 's :=
X  #1 'nameptr :=
X  ""
X  s num.names$ 'numnames :=
X  numnames 'namesleft :=
X    { namesleft #0 > }
X    { nameptr #1 >
X	{ "   " * }
X	'skip$
X      if$
X      s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ 't :=
X      nameptr numnames = t "others" = and
X	{ "et al" * }
X	{ t sortify * }
X      if$
X      nameptr #1 + 'nameptr :=
X      namesleft #1 - 'namesleft :=
X    }
X  while$
X}
X
XFUNCTION {sort.format.title}
X{ 't :=
X  "A " #2
X    "An " #3
X      "The " #4 t chop.word
X    chop.word
X  chop.word
X  sortify
X  #1 global.max$ substring$
X}
X
XFUNCTION {author.sort}
X{ author empty$
X    { key empty$
X	{ "to sort, need author or key in " cite$ * warning$
X	  ""
X	}
X	{ key sortify }
X      if$
X    }
X    { author sort.format.names }
X  if$
X}
X
XFUNCTION {author.editor.sort}
X{ author empty$
X    { editor empty$
X	{ key empty$
X	    { "to sort, need author, editor, or key in " cite$ * warning$
X	      ""
X	    }
X	    { key sortify }
X	  if$
X	}
X	{ editor sort.format.names }
X      if$
X    }
X    { author sort.format.names }
X  if$
X}
X
XFUNCTION {author.organization.sort}
X{ author empty$
X    { organization empty$
X	{ key empty$
X	    { "to sort, need author, organization, or key in " cite$ * warning$
X	      ""
X	    }
X	    { key sortify }
X	  if$
X	}
X	{ "The " #4 organization chop.word sortify }
X      if$
X    }
X    { author sort.format.names }
X  if$
X}
X
XFUNCTION {editor.organization.sort}
X{ editor empty$
X    { organization empty$
X	{ key empty$
X	    { "to sort, need editor, organization, or key in " cite$ * warning$
X	      ""
X	    }
X	    { key sortify }
X	  if$
X	}
X	{ "The " #4 organization chop.word sortify }
X      if$
X    }
X    { editor sort.format.names }
X  if$
X}
X
XFUNCTION {presort}
X{ calc.label
X  sort.label
X  "    "
X  *
X  type$ "book" =
X  type$ "inbook" =
X  or
X    'author.editor.sort
X    { type$ "proceedings" =
X	'editor.organization.sort
X	{ type$ "manual" =
X	    'author.organization.sort
X	    'author.sort
X	  if$
X	}
X      if$
X    }
X  if$
X  *
X  "    "
X  *
X  year field.or.null sortify
X  *
X  "    "
X  *
X  title field.or.null
X  sort.format.title
X  *
X  #1 entry.max$ substring$
X  'sort.key$ :=
X}
X
XITERATE {presort}
X
XSORT
X
XSTRINGS { longest.label last.sort.label next.extra }
X
XINTEGERS { longest.label.width last.extra.num }
X
XFUNCTION {initialize.longest.label}
X{ "" 'longest.label :=
X  #0 int.to.chr$ 'last.sort.label :=
X  "" 'next.extra :=
X  #0 'longest.label.width :=
X  #0 'last.extra.num :=
X}
X
XFUNCTION {forward.pass}
X{ last.sort.label sort.label =
X    { last.extra.num #1 + 'last.extra.num :=
X      last.extra.num int.to.chr$ 'extra.label :=
X    }
X    { "a" chr.to.int$ 'last.extra.num :=
X      "" 'extra.label :=
X      sort.label 'last.sort.label :=
X    }
X  if$
X}
X
XFUNCTION {reverse.pass}
X{ next.extra "b" =
X    { "a" 'extra.label := }
X    'skip$
X  if$
X  cite$ 'label := % was: label extra.label * 'label :=
X  label width$ longest.label.width >
X    { label 'longest.label :=
X      label width$ 'longest.label.width :=
X    }
X    'skip$
X  if$
X  extra.label 'next.extra :=
X}
X
XEXECUTE {initialize.longest.label}
X
XITERATE {forward.pass}
X
XREVERSE {reverse.pass}
X
XFUNCTION {begin.bib}
X{ et.al.char.used
X    { "\newcommand{\etalchar}[1]{$^{#1}$}" write$ newline$ }
X    'skip$
X  if$
X  preamble$ empty$
X    'skip$
X    { preamble$ write$ newline$ }
X  if$
X  "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
X}
X
XEXECUTE {begin.bib}
X
XEXECUTE {init.state.consts}
X
XITERATE {call.type$}
X
XFUNCTION {end.bib}
X{ newline$
X  "\end{thebibliography}" write$ newline$
X}
X
XEXECUTE {end.bib}
END_OF_FILE
if test 21396 -ne `wc -c <'btt/cite.bst'`; then
    echo shar: \"'btt/cite.bst'\" unpacked with wrong size!
fi
# end of 'btt/cite.bst'
fi
if test -f 'btt/printbib.sty' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'btt/printbib.sty'\"
else
echo shar: Extracting \"'btt/printbib.sty'\" \(317 characters\)
sed "s/^X//" >'btt/printbib.sty' <<'END_OF_FILE'
X\def\thebibliography#1{\@mkboth{REFERENCES}{REFERENCES}\list
X  {[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}\leftmargin\labelwidth
X    \advance\leftmargin\labelsep
X    \usecounter{enumi}}
X    \def\newblock{\hskip .11em plus .33em minus .07em}
X    \sloppy\clubpenalty4000\widowpenalty4000
X    \sfcode`\.=1000\relax}
END_OF_FILE
if test 317 -ne `wc -c <'btt/printbib.sty'`; then
    echo shar: \"'btt/printbib.sty'\" unpacked with wrong size!
fi
# end of 'btt/printbib.sty'
fi
echo shar: End of shell archive.
exit 0
--
Paul King							       _--_|\
Dept. of Computer Science, Univ. of Queensland			      /      X
Queensland, Australia, 4072					      \_.--._/
king@cs.uq.oz.au (ACSNET)					            v