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