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