1%%% fullname.bst
2%%%
3%%% Stuart M. Shieber
4%%% Mon Mar 30 17:23:36 EST 1992
5
6%%% Modification of BibTeX style file "aaai-named" by Peter
7%%% Patel-Schneider
8
9%%% Intended for use with the style file "fullname.sty"
10
11% BibTeX `aaai-named' style file for BibTeX version 0.99c, LaTeX version 2.09
12% This version was made by modifying the master file made by
13% Oren Patashnik (PATASHNIK@SCORE.STANFORD.EDU)
14
15% Copyright (C) 1985, all rights reserved.
16% Modifications Copyright 1988, Peter F. Patel-Schneider
17% Copying of this file is authorized only if either
18% (1) you make absolutely no changes to your copy, including name, or
19% (2) if you do make changes, you name it something other than
20% btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
21% This restriction helps ensure that all standard styles are identical.
22
23% There are undoubtably bugs in this style.  If you make bug fixes,
24% improvements, etc.  please let me know.  My e-mail address is:
25%	pfps@spar.slb.com
26
27%   Citation format: [author-last-name, year]
28%		     [author-last-name and author-last-name, year]
29%		     [author-last-name {\em et al.}, year]
30%
31%   Reference list ordering: alphabetical by author or whatever passes
32%	for author in the absence of one.
33%
34% This BibTeX style has support for short (year only) citations.  This
35% is done by having the citations actually look like
36%         \citename{name-info, }year
37% The LaTeX style has to have the following
38%     \let\@internalcite\cite
39%     \def\cite{\def\citename##1{##1}\@internalcite}
40%     \def\shortcite{\def\citename##1{}\@internalcite}
41%     \def\@biblabel#1{\def\citename##1{##1}[#1]\hfill}
42% which makes \shortcite the macro for short citations.
43
44%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45% Changes made by SMS for thesis style
46%   no emphasis on "et al."
47%   "Ph.D." includes periods (not "PhD")
48%   moved year to immediately after author's name
49% Changes made by SMS for compatability with MIT Press style
50%   inverted first and last names for first author
51%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52ENTRY
53  { address
54    author
55    booktitle
56    chapter
57    edition
58    editor
59    howpublished
60    institution
61    journal
62    key
63    month
64    note
65    number
66    organization
67    pages
68    publisher
69    school
70    series
71    title
72    type
73    volume
74    year
75  }
76  {}
77  { label extra.label sort.label }
78
79INTEGERS { output.state before.all mid.sentence after.sentence after.block }
80
81FUNCTION {init.state.consts}
82{ #0 'before.all :=
83  #1 'mid.sentence :=
84  #2 'after.sentence :=
85  #3 'after.block :=
86}
87
88STRINGS { s t }
89
90FUNCTION {output.nonnull}
91{ 's :=
92  output.state mid.sentence =
93    { ", " * write$ }
94    { output.state after.block =
95	{ add.period$ write$
96	  newline$
97	  "\newblock " write$
98	}
99	{ output.state before.all =
100	    'write$
101	    { add.period$ " " * write$ }
102	  if$
103	}
104      if$
105      mid.sentence 'output.state :=
106    }
107  if$
108  s
109}
110
111FUNCTION {output}
112{ duplicate$ empty$
113    'pop$
114    'output.nonnull
115  if$
116}
117
118FUNCTION {output.check}
119{ 't :=
120  duplicate$ empty$
121    { pop$ "empty " t * " in " * cite$ * warning$ }
122    'output.nonnull
123  if$
124}
125
126FUNCTION {output.bibitem}
127{ newline$
128
129  "\bibitem[" write$
130  label write$
131  "]{" write$
132
133  cite$ write$
134  "}" write$
135  newline$
136  ""
137  before.all 'output.state :=
138}
139
140FUNCTION {fin.entry}
141{ add.period$
142  write$
143  newline$
144}
145
146FUNCTION {new.block}
147{ output.state before.all =
148    'skip$
149    { after.block 'output.state := }
150  if$
151}
152
153FUNCTION {new.sentence}
154{ output.state after.block =
155    'skip$
156    { output.state before.all =
157	'skip$
158	{ after.sentence 'output.state := }
159      if$
160    }
161  if$
162}
163
164FUNCTION {not}
165{   { #0 }
166    { #1 }
167  if$
168}
169
170FUNCTION {and}
171{   'skip$
172    { pop$ #0 }
173  if$
174}
175
176FUNCTION {or}
177{   { pop$ #1 }
178    'skip$
179  if$
180}
181
182FUNCTION {new.block.checka}
183{ empty$
184    'skip$
185    'new.block
186  if$
187}
188
189FUNCTION {new.block.checkb}
190{ empty$
191  swap$ empty$
192  and
193    'skip$
194    'new.block
195  if$
196}
197
198FUNCTION {new.sentence.checka}
199{ empty$
200    'skip$
201    'new.sentence
202  if$
203}
204
205FUNCTION {new.sentence.checkb}
206{ empty$
207  swap$ empty$
208  and
209    'skip$
210    'new.sentence
211  if$
212}
213
214FUNCTION {field.or.null}
215{ duplicate$ empty$
216    { pop$ "" }
217    'skip$
218  if$
219}
220
221FUNCTION {emphasize}
222{ duplicate$ empty$
223    { pop$ "" }
224    { "{\em " swap$ * "}" * }
225  if$
226}
227
228INTEGERS { nameptr namesleft numnames }
229
230%%% This function reverses the first name in the author list, e.g.,
231%%% Dewey, John, Thomas Cheatham, and Elias Howe.
232%%% For editor names, no reversal is appropriate, so
233%%% format.names.unreversed is used.
234
235FUNCTION {format.names}
236{ 's :=
237  #1 'nameptr :=
238  s num.names$ 'numnames :=
239  numnames 'namesleft :=
240    { namesleft #0 > }
241
242    { s nameptr
243	   nameptr #1 >
244              { "{ff~}{vv~}{ll}{, jj}" }
245              { "{vv~}{ll}{, jj}{, ff}" }
246	   if$
247        format.name$ 't :=
248      nameptr #1 >
249	{ namesleft #1 >
250	    { ", " * t * }
251	    { numnames #2 >
252		{ "," * }
253		'skip$
254	      if$
255	      t "others" =
256		{ " et~al." * }
257		{ " and " * t * }
258	      if$
259	    }
260	  if$
261	}
262	't
263      if$
264      nameptr #1 + 'nameptr :=
265      namesleft #1 - 'namesleft :=
266    }
267  while$
268}
269
270FUNCTION {format.authors}
271{ author empty$
272    { "" }
273    { author format.names }
274  if$
275}
276
277FUNCTION {format.names.unreversed}
278{ 's :=
279  #1 'nameptr :=
280  s num.names$ 'numnames :=
281  numnames 'namesleft :=
282    { namesleft #0 > }
283
284    { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
285
286      nameptr #1 >
287	{ namesleft #1 >
288	    { ", " * t * }
289	    { numnames #2 >
290		{ "," * }
291		'skip$
292	      if$
293	      t "others" =
294		{ " et~al." * }
295		{ " and " * t * }
296	      if$
297	    }
298	  if$
299	}
300	't
301      if$
302      nameptr #1 + 'nameptr :=
303      namesleft #1 - 'namesleft :=
304    }
305  while$
306}
307
308FUNCTION {format.editors}
309{ editor empty$
310    { "" }
311    { editor format.names
312      editor num.names$ #1 >
313	{ ", editors" * }
314	{ ", editor" * }
315      if$
316    }
317  if$
318}
319
320FUNCTION {format.editors.unreversed}
321{ editor empty$
322    { "" }
323    { editor format.names.unreversed
324      editor num.names$ #1 >
325	{ ", editors" * }
326	{ ", editor" * }
327      if$
328    }
329  if$
330}
331
332FUNCTION {format.title}
333{ title empty$
334    { "" }
335
336    { title "t" change.case$ }
337
338  if$
339}
340
341FUNCTION {n.dashify}
342{ 't :=
343  ""
344    { t empty$ not }
345    { t #1 #1 substring$ "-" =
346	{ t #1 #2 substring$ "--" = not
347	    { "--" *
348	      t #2 global.max$ substring$ 't :=
349	    }
350	    {   { t #1 #1 substring$ "-" = }
351		{ "-" *
352		  t #2 global.max$ substring$ 't :=
353		}
354	      while$
355	    }
356	  if$
357	}
358	{ t #1 #1 substring$ *
359	  t #2 global.max$ substring$ 't :=
360	}
361      if$
362    }
363  while$
364}
365
366FUNCTION {format.date}
367{ year empty$
368    { month empty$
369	{ "" }
370	{ "there's a month but no year in " cite$ * warning$
371	  month
372	}
373      if$
374    }
375    { month empty$
376	{ "" }
377	{ month }
378      if$
379    }
380  if$
381}
382
383FUNCTION {format.btitle}
384{ title emphasize
385}
386
387FUNCTION {tie.or.space.connect}
388{ duplicate$ text.length$ #3 <
389    { "~" }
390    { " " }
391  if$
392  swap$ * *
393}
394
395FUNCTION {either.or.check}
396{ empty$
397    'pop$
398    { "can't use both " swap$ * " fields in " * cite$ * warning$ }
399  if$
400}
401
402FUNCTION {format.bvolume}
403{ volume empty$
404    { "" }
405    { "volume" volume tie.or.space.connect
406      series empty$
407	'skip$
408	{ " of " * series emphasize * }
409      if$
410      "volume and number" number either.or.check
411    }
412  if$
413}
414
415FUNCTION {format.number.series}
416{ volume empty$
417    { number empty$
418	{ series field.or.null }
419	{ output.state mid.sentence =
420	    { "number" }
421	    { "Number" }
422	  if$
423	  number tie.or.space.connect
424	  series empty$
425	    { "there's a number but no series in " cite$ * warning$ }
426	    { " in " * series * }
427	  if$
428	}
429      if$
430    }
431    { "" }
432  if$
433}
434
435FUNCTION {format.edition}
436{ edition empty$
437    { "" }
438    { output.state mid.sentence =
439	{ edition "l" change.case$ " edition" * }
440	{ edition "t" change.case$ " edition" * }
441      if$
442    }
443  if$
444}
445
446INTEGERS { multiresult }
447
448FUNCTION {multi.page.check}
449{ 't :=
450  #0 'multiresult :=
451    { multiresult not
452      t empty$ not
453      and
454    }
455    { t #1 #1 substring$
456      duplicate$ "-" =
457      swap$ duplicate$ "," =
458      swap$ "+" =
459      or or
460	{ #1 'multiresult := }
461	{ t #2 global.max$ substring$ 't := }
462      if$
463    }
464  while$
465  multiresult
466}
467
468FUNCTION {format.pages}
469{ pages empty$
470    { "" }
471    { pages multi.page.check
472	{ "pages" pages n.dashify tie.or.space.connect }
473	{ "page" pages tie.or.space.connect }
474      if$
475    }
476  if$
477}
478
479FUNCTION {format.year.label}
480{ year extra.label *
481}
482
483FUNCTION {format.vol.num.pages}
484{ volume field.or.null
485  number empty$
486    'skip$
487    { "(" number * ")" * *
488      volume empty$
489	{ "there's a number but no volume in " cite$ * warning$ }
490	'skip$
491      if$
492    }
493  if$
494  pages empty$
495    'skip$
496    { duplicate$ empty$
497	{ pop$ format.pages }
498	{ ":" * pages n.dashify * }
499      if$
500    }
501  if$
502}
503
504FUNCTION {format.chapter.pages}
505{ chapter empty$
506    'format.pages
507    { type empty$
508	{ "chapter" }
509	{ type "l" change.case$ }
510      if$
511      chapter tie.or.space.connect
512      pages empty$
513	'skip$
514	{ ", " * format.pages * }
515      if$
516    }
517  if$
518}
519
520FUNCTION {format.in.ed.booktitle}
521{ booktitle empty$
522    { "" }
523    { editor empty$
524	{ "In " booktitle emphasize * }
525	{ "In " format.editors.unreversed * ", " * booktitle emphasize * }
526      if$
527    }
528  if$
529}
530
531FUNCTION {empty.misc.check}
532{ author empty$ title empty$ howpublished empty$
533  month empty$ year empty$ note empty$
534  and and and and and
535
536  key empty$ not and
537
538    { "all relevant fields are empty in " cite$ * warning$ }
539    'skip$
540  if$
541}
542
543FUNCTION {format.thesis.type}
544{ type empty$
545    'skip$
546    { pop$
547      type "t" change.case$
548    }
549  if$
550}
551
552FUNCTION {format.tr.number}
553{ type empty$
554    { "Technical Report" }
555    'type
556  if$
557  number empty$
558    { "t" change.case$ }
559    { number tie.or.space.connect }
560  if$
561}
562
563FUNCTION {format.article.crossref}
564{ key empty$
565    { journal empty$
566	{ "need key or journal for " cite$ * " to crossref " * crossref *
567	  warning$
568	  ""
569	}
570	{ "In {\em " journal * "\/}" * }
571      if$
572    }
573    { "In " key * }
574  if$
575  " \cite{" * crossref * "}" *
576}
577
578FUNCTION {format.crossref.editor}
579{ editor #1 "{vv~}{ll}" format.name$
580  editor num.names$ duplicate$
581  #2 >
582    { pop$ " et~al." * }
583    { #2 <
584	'skip$
585	{ editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
586	    { " et~al." * }
587	    { " and " * editor #2 "{vv~}{ll}" format.name$ * }
588	  if$
589	}
590      if$
591    }
592  if$
593}
594
595FUNCTION {format.book.crossref}
596{ volume empty$
597    { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
598      "In "
599    }
600    { "Volume" volume tie.or.space.connect
601      " of " *
602    }
603  if$
604  editor empty$
605  editor field.or.null author field.or.null =
606  or
607    { key empty$
608	{ series empty$
609	    { "need editor, key, or series for " cite$ * " to crossref " *
610	      crossref * warning$
611	      "" *
612	    }
613	    { "{\em " * series * "\/}" * }
614	  if$
615	}
616	{ key * }
617      if$
618    }
619    { format.crossref.editor * }
620  if$
621  " \cite{" * crossref * "}" *
622}
623
624FUNCTION {format.incoll.inproc.crossref}
625{ editor empty$
626  editor field.or.null author field.or.null =
627  or
628    { key empty$
629	{ booktitle empty$
630	    { "need editor, key, or booktitle for " cite$ * " to crossref " *
631	      crossref * warning$
632	      ""
633	    }
634	    { "In {\em " booktitle * "\/}" * }
635	  if$
636	}
637	{ "In " key * }
638      if$
639    }
640    { "In " format.crossref.editor * }
641  if$
642  " \cite{" * crossref * "}" *
643}
644
645FUNCTION {article}
646{ output.bibitem
647  format.authors "author" output.check
648  new.block
649  format.year.label "year" output.check
650  new.block
651  format.title "title" output.check
652  new.block
653  crossref missing$
654    { journal emphasize "journal" output.check
655      format.vol.num.pages output
656      format.date output
657    }
658    { format.article.crossref output.nonnull
659      format.pages output
660    }
661  if$
662  new.block
663  note output
664  fin.entry
665}
666
667FUNCTION {book}
668{ output.bibitem
669  author empty$
670    { format.editors "author and editor" output.check }
671    { format.authors output.nonnull
672      crossref missing$
673	{ "author and editor" editor either.or.check }
674	'skip$
675      if$
676    }
677  if$
678  new.block
679  format.year.label "year" output.check
680  new.block
681  format.btitle "title" output.check
682  crossref missing$
683    { format.bvolume output
684      new.block
685      format.number.series output
686      new.sentence
687      publisher "publisher" output.check
688      address output
689    }
690    { new.block
691      format.book.crossref output.nonnull
692    }
693  if$
694  format.edition output
695  format.date output
696  new.block
697  note output
698  fin.entry
699}
700
701FUNCTION {booklet}
702{ output.bibitem
703  format.authors output
704  new.block
705  format.year.label "year" output.check
706  new.block
707  format.title "title" output.check
708  howpublished address new.block.checkb
709  howpublished output
710  address output
711  format.date output
712  new.block
713  note output
714  fin.entry
715}
716
717FUNCTION {inbook}
718{ output.bibitem
719  author empty$
720    { format.editors "author and editor" output.check }
721    { format.authors output.nonnull
722      crossref missing$
723	{ "author and editor" editor either.or.check }
724	'skip$
725      if$
726    }
727  if$
728  format.year.label "year" output.check
729  new.block
730  format.btitle "title" output.check
731  crossref missing$
732    { format.bvolume output
733      format.chapter.pages "chapter and pages" output.check
734      new.block
735      format.number.series output
736      new.sentence
737      publisher "publisher" output.check
738      address output
739    }
740    { format.chapter.pages "chapter and pages" output.check
741      new.block
742      format.book.crossref output.nonnull
743    }
744  if$
745  format.edition output
746  format.date output
747  new.block
748  note output
749  fin.entry
750}
751
752FUNCTION {incollection}
753{ output.bibitem
754  format.authors "author" output.check
755  new.block
756  format.year.label "year" output.check
757  new.block
758  format.title "title" output.check
759  new.block
760  crossref missing$
761    { format.in.ed.booktitle "booktitle" output.check
762      format.bvolume output
763      format.number.series output
764      new.sentence
765      publisher "publisher" output.check
766      address output
767      format.edition output
768      format.date output
769      format.chapter.pages output
770    }
771    { format.incoll.inproc.crossref output.nonnull
772      format.chapter.pages output
773    }
774  if$
775  new.block
776  note output
777  fin.entry
778}
779
780FUNCTION {inproceedings}
781{ output.bibitem
782  format.authors "author" output.check
783  new.block
784  format.year.label "year" output.check
785  new.block
786  format.title "title" output.check
787  new.block
788  crossref missing$
789    { format.in.ed.booktitle "booktitle" output.check
790      format.bvolume output
791      format.number.series output
792      format.pages output
793      address empty$
794	{ organization publisher new.sentence.checkb
795	  organization output
796	  publisher output
797	  format.date output
798	}
799	{ address output.nonnull
800	  format.date output
801	  new.sentence
802	  organization output
803	  publisher output
804	}
805      if$
806    }
807    { format.incoll.inproc.crossref output.nonnull
808      format.pages output
809    }
810  if$
811  new.block
812  note output
813  fin.entry
814}
815
816FUNCTION {conference} { inproceedings }
817
818FUNCTION {manual}
819{ output.bibitem
820  author empty$
821    { organization empty$
822	'skip$
823	{ organization output.nonnull
824	  address output
825	}
826      if$
827    }
828    { format.authors output.nonnull }
829  if$
830  format.year.label "year" output.check
831  new.block
832  new.block
833  format.btitle "title" output.check
834  author empty$
835    { organization empty$
836	{ address new.block.checka
837	  address output
838	}
839	'skip$
840      if$
841    }
842    { organization address new.block.checkb
843      organization output
844      address output
845    }
846  if$
847  format.edition output
848  format.date output
849  new.block
850  note output
851  fin.entry
852}
853
854FUNCTION {mastersthesis}
855{ output.bibitem
856  format.authors "author" output.check
857  new.block
858  format.year.label "year" output.check
859  new.block
860  format.title "title" output.check
861  new.block
862  "Master's thesis" format.thesis.type output.nonnull
863  school "school" output.check
864  address output
865  format.date output
866  new.block
867  note output
868  fin.entry
869}
870
871FUNCTION {misc}
872{ output.bibitem
873  format.authors output
874  new.block
875  format.year.label output
876  new.block
877  title howpublished new.block.checkb
878  format.title output
879  howpublished new.block.checka
880  howpublished output
881  format.date output
882  new.block
883  note output
884  fin.entry
885  empty.misc.check
886}
887
888FUNCTION {phdthesis}
889{ output.bibitem
890  format.authors "author" output.check
891  new.block
892  format.year.label "year" output.check
893  new.block
894  format.btitle "title" output.check
895  new.block
896  "{Ph.D.} thesis" format.thesis.type output.nonnull
897  school "school" output.check
898  address output
899  format.date output
900  new.block
901  note output
902  fin.entry
903}
904
905FUNCTION {proceedings}
906{ output.bibitem
907  editor empty$
908    { organization output }
909    { format.editors output.nonnull }
910  if$
911  new.block
912  format.year.label "year" output.check
913  new.block
914  format.btitle "title" output.check
915  format.bvolume output
916  format.number.series output
917  address empty$
918    { editor empty$
919	{ publisher new.sentence.checka }
920	{ organization publisher new.sentence.checkb
921	  organization output
922	}
923      if$
924      publisher output
925      format.date output
926    }
927    { address output.nonnull
928      format.date output
929      new.sentence
930      editor empty$
931	'skip$
932	{ organization output }
933      if$
934      publisher output
935    }
936  if$
937  new.block
938  note output
939  fin.entry
940}
941
942FUNCTION {techreport}
943{ output.bibitem
944  format.authors "author" output.check
945  new.block
946  format.year.label "year" output.check
947  new.block
948  format.title "title" output.check
949  new.block
950  format.tr.number output.nonnull
951  institution "institution" output.check
952  address output
953  format.date output
954  new.block
955  note output
956  fin.entry
957}
958
959FUNCTION {unpublished}
960{ output.bibitem
961  format.authors "author" output.check
962  new.block
963  format.year.label "year" output.check
964  new.block
965  format.title "title" output.check
966  new.block
967  note "note" output.check
968  format.date output
969  fin.entry
970}
971
972FUNCTION {default.type} { misc }
973
974MACRO {jan} {"January"}
975
976MACRO {feb} {"February"}
977
978MACRO {mar} {"March"}
979
980MACRO {apr} {"April"}
981
982MACRO {may} {"May"}
983
984MACRO {jun} {"June"}
985
986MACRO {jul} {"July"}
987
988MACRO {aug} {"August"}
989
990MACRO {sep} {"September"}
991
992MACRO {oct} {"October"}
993
994MACRO {nov} {"November"}
995
996MACRO {dec} {"December"}
997
998MACRO {acmcs} {"ACM Computing Surveys"}
999
1000MACRO {acta} {"Acta Informatica"}
1001
1002MACRO {cacm} {"Communications of the ACM"}
1003
1004MACRO {ibmjrd} {"IBM Journal of Research and Development"}
1005
1006MACRO {ibmsj} {"IBM Systems Journal"}
1007
1008MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
1009
1010MACRO {ieeetc} {"IEEE Transactions on Computers"}
1011
1012MACRO {ieeetcad}
1013 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
1014
1015MACRO {ipl} {"Information Processing Letters"}
1016
1017MACRO {jacm} {"Journal of the ACM"}
1018
1019MACRO {jcss} {"Journal of Computer and System Sciences"}
1020
1021MACRO {scp} {"Science of Computer Programming"}
1022
1023MACRO {sicomp} {"SIAM Journal on Computing"}
1024
1025MACRO {tocs} {"ACM Transactions on Computer Systems"}
1026
1027MACRO {tods} {"ACM Transactions on Database Systems"}
1028
1029MACRO {tog} {"ACM Transactions on Graphics"}
1030
1031MACRO {toms} {"ACM Transactions on Mathematical Software"}
1032
1033MACRO {toois} {"ACM Transactions on Office Information Systems"}
1034
1035MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
1036
1037MACRO {tcs} {"Theoretical Computer Science"}
1038
1039READ
1040
1041FUNCTION {sortify}
1042{ purify$
1043  "l" change.case$
1044}
1045
1046INTEGERS { len }
1047
1048FUNCTION {chop.word}
1049{ 's :=
1050  'len :=
1051  s #1 len substring$ =
1052    { s len #1 + global.max$ substring$ }
1053    's
1054  if$
1055}
1056
1057INTEGERS { et.al.char.used }
1058
1059FUNCTION {initialize.et.al.char.used}
1060{ #0 'et.al.char.used :=
1061}
1062
1063EXECUTE {initialize.et.al.char.used}
1064
1065FUNCTION {format.lab.names}
1066{ 's :=
1067  s num.names$ 'numnames :=
1068
1069  numnames #1 =
1070    { s #1 "{vv }{ll}" format.name$ }
1071    { numnames #2 =
1072        { s #1 "{vv }{ll }and " format.name$ s #2 "{vv }{ll}" format.name$ *
1073        }
1074        { numnames #3 =
1075             { s #1 "{vv }{ll}, " format.name$ s #2 "{vv }{ll}, and "
1076		format.name$ * s #3 "{vv }{ll}" format.name$ * }
1077             { s #1 "{vv }{ll }\bgroup et al.\egroup " format.name$ }
1078          if$
1079        }
1080      if$
1081    }
1082  if$
1083
1084}
1085
1086FUNCTION {author.key.label}
1087{ author empty$
1088    { key empty$
1089
1090	{ cite$ #1 #3 substring$ }
1091
1092	{ key #3 text.prefix$ }
1093      if$
1094    }
1095    { author format.lab.names }
1096  if$
1097}
1098
1099FUNCTION {author.editor.key.label}
1100{ author empty$
1101    { editor empty$
1102	{ key empty$
1103
1104	    { cite$ #1 #3 substring$ }
1105
1106	    { key #3 text.prefix$ }
1107	  if$
1108	}
1109	{ editor format.lab.names }
1110      if$
1111    }
1112    { author format.lab.names }
1113  if$
1114}
1115
1116FUNCTION {author.key.organization.label}
1117{ author empty$
1118    { key empty$
1119	{ organization empty$
1120
1121	    { cite$ #1 #3 substring$ }
1122
1123	    { "The " #4 organization chop.word #3 text.prefix$ }
1124	  if$
1125	}
1126	{ key #3 text.prefix$ }
1127      if$
1128    }
1129    { author format.lab.names }
1130  if$
1131}
1132
1133FUNCTION {editor.key.organization.label}
1134{ editor empty$
1135    { key empty$
1136	{ organization empty$
1137
1138	    { cite$ #1 #3 substring$ }
1139
1140	    { "The " #4 organization chop.word #3 text.prefix$ }
1141	  if$
1142	}
1143	{ key #3 text.prefix$ }
1144      if$
1145    }
1146    { editor format.lab.names }
1147  if$
1148}
1149
1150FUNCTION {calc.label}
1151{ type$ "book" =
1152  type$ "inbook" =
1153  or
1154    'author.editor.key.label
1155    { type$ "proceedings" =
1156	'editor.key.organization.label
1157	{ type$ "manual" =
1158	    'author.key.organization.label
1159	    'author.key.label
1160	  if$
1161	}
1162      if$
1163    }
1164  if$
1165  duplicate$
1166
1167  "\protect\citename{" swap$ * "}" *
1168  year field.or.null purify$ *
1169  'label :=
1170  year field.or.null purify$ *
1171
1172  sortify 'sort.label :=
1173}
1174
1175FUNCTION {sort.format.names}
1176{ 's :=
1177  #1 'nameptr :=
1178  ""
1179  s num.names$ 'numnames :=
1180  numnames 'namesleft :=
1181    { namesleft #0 > }
1182    { nameptr #1 >
1183	{ "   " * }
1184	'skip$
1185      if$
1186
1187      s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ 't :=
1188
1189      nameptr numnames = t "others" = and
1190	{ "et al" * }
1191	{ t sortify * }
1192      if$
1193      nameptr #1 + 'nameptr :=
1194      namesleft #1 - 'namesleft :=
1195    }
1196  while$
1197}
1198
1199FUNCTION {sort.format.title}
1200{ 't :=
1201  "A " #2
1202    "An " #3
1203      "The " #4 t chop.word
1204    chop.word
1205  chop.word
1206  sortify
1207  #1 global.max$ substring$
1208}
1209
1210FUNCTION {author.sort}
1211{ author empty$
1212    { key empty$
1213	{ "to sort, need author or key in " cite$ * warning$
1214	  ""
1215	}
1216	{ key sortify }
1217      if$
1218    }
1219    { author sort.format.names }
1220  if$
1221}
1222
1223FUNCTION {author.editor.sort}
1224{ author empty$
1225    { editor empty$
1226	{ key empty$
1227	    { "to sort, need author, editor, or key in " cite$ * warning$
1228	      ""
1229	    }
1230	    { key sortify }
1231	  if$
1232	}
1233	{ editor sort.format.names }
1234      if$
1235    }
1236    { author sort.format.names }
1237  if$
1238}
1239
1240FUNCTION {author.organization.sort}
1241{ author empty$
1242    { organization empty$
1243	{ key empty$
1244	    { "to sort, need author, organization, or key in " cite$ * warning$
1245	      ""
1246	    }
1247	    { key sortify }
1248	  if$
1249	}
1250	{ "The " #4 organization chop.word sortify }
1251      if$
1252    }
1253    { author sort.format.names }
1254  if$
1255}
1256
1257FUNCTION {editor.organization.sort}
1258{ editor empty$
1259    { organization empty$
1260	{ key empty$
1261	    { "to sort, need editor, organization, or key in " cite$ * warning$
1262	      ""
1263	    }
1264	    { key sortify }
1265	  if$
1266	}
1267	{ "The " #4 organization chop.word sortify }
1268      if$
1269    }
1270    { editor sort.format.names }
1271  if$
1272}
1273
1274FUNCTION {presort}
1275
1276{ " "
1277  calc.label
1278  sort.label
1279  pop$
1280  type$ "book" =
1281
1282  type$ "inbook" =
1283  or
1284    'author.editor.sort
1285    { type$ "proceedings" =
1286	'editor.organization.sort
1287	{ type$ "manual" =
1288	    'author.organization.sort
1289	    'author.sort
1290	  if$
1291	}
1292      if$
1293    }
1294  if$
1295
1296  *
1297
1298  "    "
1299  *
1300  year field.or.null sortify
1301  *
1302  "    "
1303  *
1304  title field.or.null
1305  sort.format.title
1306  *
1307  #1 entry.max$ substring$
1308  'sort.key$ :=
1309}
1310
1311ITERATE {presort}
1312
1313SORT
1314
1315STRINGS { longest.label last.sort.label next.extra }
1316
1317INTEGERS { longest.label.width last.extra.num }
1318
1319FUNCTION {initialize.longest.label}
1320{ "" 'longest.label :=
1321  #0 int.to.chr$ 'last.sort.label :=
1322  "" 'next.extra :=
1323  #0 'longest.label.width :=
1324  #0 'last.extra.num :=
1325}
1326
1327FUNCTION {forward.pass}
1328{ last.sort.label sort.label =
1329    { last.extra.num #1 + 'last.extra.num :=
1330      last.extra.num int.to.chr$ 'extra.label :=
1331    }
1332    { "a" chr.to.int$ 'last.extra.num :=
1333      "" 'extra.label :=
1334      sort.label 'last.sort.label :=
1335    }
1336  if$
1337}
1338
1339FUNCTION {reverse.pass}
1340{ next.extra "b" =
1341    { "a" 'extra.label := }
1342    'skip$
1343  if$
1344  label extra.label * 'label :=
1345  label width$ longest.label.width >
1346    { label 'longest.label :=
1347      label width$ 'longest.label.width :=
1348    }
1349    'skip$
1350  if$
1351  extra.label 'next.extra :=
1352}
1353
1354EXECUTE {initialize.longest.label}
1355
1356ITERATE {forward.pass}
1357
1358REVERSE {reverse.pass}
1359
1360FUNCTION {begin.bib}
1361
1362{ et.al.char.used
1363    { "\newcommand{\etalchar}[1]{$^{#1}$}" write$ newline$ }
1364    'skip$
1365  if$
1366  preamble$ empty$
1367
1368    'skip$
1369    { preamble$ write$ newline$ }
1370  if$
1371
1372  "\begin{thebibliography}{" "}" * write$ newline$
1373
1374}
1375
1376EXECUTE {begin.bib}
1377
1378EXECUTE {init.state.consts}
1379
1380ITERATE {call.type$}
1381
1382FUNCTION {end.bib}
1383{ newline$
1384  "\end{thebibliography}" write$ newline$
1385}
1386
1387EXECUTE {end.bib}
1388