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