6055ac2adb4d23e2b4e34bec686741b614f01f43
[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       urlpath empty$
624         'skip$
625         { do.period " Path: " * urlpath * }
626       if$
627     }
628   if$
629 }
630
631 FUNCTION {format.article.crossref}
632 { %key empty$
633     %{ journal empty$
634         %{ "need key or journal for " cite$ * " to crossref " * crossref *
635         %  warning$
636         %  ""
637         %}
638         %{ "In {\em " journal * "\/}" * }
639       %if$
640     %}
641     %{ "In " key * }
642   %if$
643   pages empty$ { " \citeN" } { " \citeN[" format.chapter.pages * "]" * } if$
644   "{" * crossref * "}" *
645   citen.used #1 + 'citen.used :=
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$ { " \citeN" } { " \citeN[" format.chapter.pages * "]" * } if$
691   "{" * crossref * "}" *
692   citen.used #1 + 'citen.used :=
693 }
694
695 FUNCTION {format.incoll.inproc.crossref}
696 {% editor empty$
697 %  editor field.or.null author field.or.null =
698 %  or
699 %    { key empty$
700 %       { booktitle empty$
701 %           { "need editor, key, or booktitle for " cite$ * " to crossref " *
702 %             crossref * warning$
703 %             ""
704 %           }
705 %           { "In {\em " booktitle * "\/}" * }
706 %         if$
707 %       }
708 %       { "In " key * }
709 %      if$
710 %    }
711 %    { "In " format.crossref.editor * }
712 %  if$
713   pages empty$ { " \citeN" } { " \citeN[" format.chapter.pages * "]" * } if$
714   "{" * crossref * "}" *
715   citen.used #1 + 'citen.used :=
716 }
717
718 FUNCTION {cite.title}
719 { title empty$ journal empty$ not and
720     { key empty$ { journal }{ key } if$ emphasize }
721     { title empty$ key empty$ and
722         { "empty title and key in " cite$ * warning$ "" }
723         { key empty$ {title}{key} if$
724           type$ "book" =
725           type$ "inbook" =
726           type$ "manual" =
727           type$ "phdthesis" =
728           type$ "proceedings" =
729           or or or or
730             { emphasize }
731             { type$ "article" =
732               %type$ "booklet" =
733               type$ "incollection" =
734               type$ "inproceedings" =
735               type$ "mastersthesis" =
736               type$ "misc" =
737               type$ "techreport" =
738               type$ "unpublished" =
739               or or or or or or
740                 {"``" swap$ * "''" *  }
741                 {}
742               if$
743             }
744           if$
745         }
746       if$
747     }
748   if$
749 }
750
751 FUNCTION {cite.label}
752 {
753   %author empty$
754   %  { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
755   %  { author 'a := }
756   %if$
757   %abbr empty$ {
758   author empty$
759     { editor empty$
760         { "" }
761         { editor }
762       if$
763     }
764     { author }
765   if$
766   duplicate$ empty$
767     { pop$ cite.title }
768     {
769       author.shared author.different =
770         { "{vv~}{ll}" format.names.custom }
771         { author.shared author.last =
772             { "{f.~}{vv~}{ll}{, jj}" format.names.custom }
773             { author.shared author.flast =
774                 { "{ff~}{vv~}{ll}{, jj}" format.names.custom }
775                 { "{vv~}{ll}" format.names.custom ", " * cite.title * }
776               if$
777             }
778           if$
779         }
780       if$
781       author.duplicate { ", " * cite.title * }{} if$
782     }
783   if$
784       %}
785       %if$
786     %}
787     %{}% abbr }
788  % if$
789 }
790
791 % TODO
792 FUNCTION {output.bibitem}
793 { newline$
794   "\bibitem[" write$
795   cite.label write$
796   "]{" write$
797   cite$ write$
798   "}" write$
799   newline$
800   ""
801   before.all 'output.state :=
802 }
803
804 FUNCTION {article}
805 { output.bibitem
806   format.authors "author" output.check
807   new.block
808   format.title "title" output.check
809   new.block
810   crossref missing$
811     { journal emphasize "journal" output.check after.title 'output.state :=
812       %format.date "year" output.check
813       %edition output
814       format.vol.num.year.pages output
815     }
816     { format.article.crossref output.nonnull
817       %format.pages output
818     }
819   if$
820   new.block
821   format.url output
822   new.block
823   note output
824   fin.entry
825 }
826
827 FUNCTION {book}
828 { output.bibitem
829   author empty$
830     { format.editors "author and editor" output.check }
831     { format.authors output.nonnull }
832   if$
833   new.block
834   format.btitle "title" output.check
835   new.sentence
836   crossref missing$
837     { author empty$ 'skip$ { format.editors.mid output new.sentence } if$
838       format.edition output
839       new.sentence
840       format.bvolume.or.num.series output
841       new.block
842       format.publisher "publisher" output.check
843       format.date "year" output.check
844     }
845     {% format.date "year" output
846       new.block
847       format.book.crossref output.nonnull
848     }
849   if$
850   new.block
851   format.url output
852   new.block
853   note output
854   fin.entry
855 }
856
857 FUNCTION {booklet}
858 { output.bibitem
859   format.authors output
860   new.block
861   format.title "title" output.check
862   howpublished address new.block.checkb
863   howpublished output
864   address output
865   format.date output
866   new.block
867   note output
868   fin.entry
869 }
870
871 FUNCTION {inbook}
872 { output.bibitem
873   author empty$
874     { format.editors "author and editor" output.check }
875     { format.authors output.nonnull }
876   if$
877   new.block
878   format.btitle "title" output.check
879   new.block
880   crossref missing$
881     { author empty$ 'skip$ { format.editors.mid output new.sentence } if$
882       format.edition output
883       new.sentence
884       format.bvolume.or.num.series output
885       new.block
886       format.publisher "publisher" output.check
887       format.date "year" output.check
888       new.sentence
889       format.chapter.pages "chapter and pages" output.check
890       %address output
891     }
892     {% format.chapter.pages "chapter and pages" output.check
893       new.block
894       format.book.crossref output.nonnull
895     }
896   if$
897   new.block
898   format.url output
899   note output
900   fin.entry
901 }
902
903 FUNCTION {incollection}
904 { output.bibitem
905   format.authors "author" output.check
906   chapter empty$
907     { new.block type output }
908     {}
909   if$
910   new.block
911   format.title "title" output.check
912   new.block
913   crossref missing$
914     { 
915       booktitle emphasize "booktitle" output.check
916       new.sentence
917       format.editors.mid "editor" output.check
918       new.block
919       format.edition output
920       new.sentence
921       format.bvolume.or.num.series output
922       new.block
923       format.publisher "publisher" output.check
924       %address output
925       format.date "year" output.check
926       new.sentence
927       format.chapter.pages output
928     }
929     { format.incoll.inproc.crossref output.nonnull
930       %format.chapter.pages output
931     }
932   if$
933   new.block
934   format.url output
935   new.block
936   note output
937   fin.entry
938 }
939
940 FUNCTION {inproceedings}
941 { output.bibitem
942   format.authors "author" output.check
943   new.block
944   format.title "title" output.check
945   new.block
946   crossref missing$
947     { %format.in.ed.booktitle "booktitle" output.check
948       booktitle "booktitle" output.check
949       new.sentence
950       format.editors.mid output
951       new.sentence
952       format.edition output
953       new.sentence
954       format.bvolume.or.num.series output
955       new.block
956       format.edition output
957       new.sentence
958       format.publisher output
959       format.date "year" output.check
960       %address empty$
961         %{ organization publisher new.sentence.checkb
962          % organization output
963          % publisher output
964          % format.date "year" output.check
965         %}
966         %{ address output.nonnull
967          % format.date "year" output.check
968          % new.sentence
969          % organization output
970          % publisher output
971         %}
972       %if$
973       new.sentence
974       format.pages output
975     }
976     { format.incoll.inproc.crossref output.nonnull
977       %format.pages output
978     }
979   if$
980   new.block
981   format.url output
982   new.block
983   note output
984   fin.entry
985 }
986
987 FUNCTION {conference} { inproceedings }
988
989 FUNCTION {manual}
990 { output.bibitem
991   author empty$
992     { organization empty$
993         'skip$
994         { organization output.nonnull
995           address output
996         }
997       if$
998     }
999     { format.authors output.nonnull }
1000   if$
1001   new.block
1002   format.btitle "title" output.check
1003   new.sentence
1004   format.edition output
1005   new.sentence
1006   author empty$
1007     { organization empty$
1008         { address new.block.checka
1009           address output
1010         }
1011         'skip$
1012       if$
1013     }
1014     { organization address new.block.checkb
1015       organization output
1016       address output
1017     }
1018   if$
1019   format.date output
1020   new.block
1021   format.url output
1022   new.block
1023   note output
1024   fin.entry
1025 }
1026
1027 FUNCTION {mastersthesis}
1028 { output.bibitem
1029   format.authors "author" output.check
1030   new.block
1031   format.title "title" output.check
1032   new.block
1033   "Diss." format.thesis.type output.nonnull
1034   after.title 'output.state :=
1035   school "school" output.check
1036   address output
1037   format.date "year" output.check
1038   new.block
1039   format.url output
1040   new.block
1041   note output
1042   fin.entry
1043 }
1044
1045 FUNCTION {misc}
1046 { output.bibitem
1047   format.authors output
1048   title howpublished new.block.checkb
1049   format.title output
1050   new.block
1051   %howpublished new.block.checka
1052   howpublished output
1053   format.date output
1054   new.block
1055   format.url output
1056   new.block
1057   note output
1058   fin.entry
1059   empty.misc.check
1060 }
1061
1062 FUNCTION {phdthesis}
1063 { output.bibitem
1064   format.authors "author" output.check
1065   new.block
1066   format.btitle "title" output.check
1067   new.block
1068   "Diss." format.thesis.type output.nonnull
1069   after.title 'output.state :=
1070   school "school" output.check
1071   address output
1072   format.date "year" output.check
1073   new.block
1074   format.url output
1075   new.block
1076   note output
1077   fin.entry
1078 }
1079
1080 FUNCTION {proceedings}
1081 { output.bibitem
1082   editor empty$
1083     { organization output }
1084     { format.editors output.nonnull }
1085   if$
1086   new.block
1087   format.btitle "title" output.check
1088   new.sentence
1089   format.bvolume.or.num.series output
1090   address empty$
1091     { editor empty$
1092         { publisher new.sentence.checka }
1093         { organization publisher new.sentence.checkb
1094           organization output
1095         }
1096       if$
1097       publisher output
1098       format.date "year" output.check
1099     }
1100     { address output.nonnull
1101       format.date "year" output.check
1102       new.sentence
1103       editor empty$
1104         'skip$
1105         { organization output }
1106       if$
1107       publisher output
1108     }
1109   if$
1110   new.block
1111   format.url output
1112   new.block
1113   note output
1114   fin.entry
1115 }
1116
1117 FUNCTION {techreport}
1118 { output.bibitem
1119   format.authors "author" output.check
1120   new.block
1121   format.title "title" output.check
1122   new.block
1123   format.tr.number output.nonnull
1124   institution "institution" output.check
1125   address output
1126   format.date "year" output.check
1127   new.block
1128   note output
1129   fin.entry
1130 }
1131
1132 FUNCTION {unpublished}
1133 { output.bibitem
1134   format.authors "author" output.check
1135   new.block
1136   format.title "title" output.check
1137   new.block
1138   format.url output
1139   new.block
1140   note "note" output.check
1141   format.date output
1142   fin.entry
1143 }
1144
1145 FUNCTION {default.type} { misc }
1146
1147 MACRO {jan} {"Jan."}
1148
1149 MACRO {feb} {"Feb."}
1150
1151 MACRO {mar} {"Mar."}
1152
1153 MACRO {apr} {"Apr."}
1154
1155 MACRO {may} {"May"}
1156
1157 MACRO {jun} {"June"}
1158
1159 MACRO {jul} {"July"}
1160
1161 MACRO {aug} {"Aug."}
1162
1163 MACRO {sep} {"Sept."}
1164
1165 MACRO {oct} {"Oct."}
1166
1167 MACRO {nov} {"Nov."}
1168
1169 MACRO {dec} {"Dec."}
1170
1171 MACRO {acmcs} {"ACM Computing Surveys"}
1172
1173 MACRO {acta} {"Acta Informatica"}
1174
1175 MACRO {cacm} {"Communications of the ACM"}
1176
1177 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
1178
1179 MACRO {ibmsj} {"IBM Systems Journal"}
1180
1181 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
1182
1183 MACRO {ieeetc} {"IEEE Transactions on Computers"}
1184
1185 MACRO {ieeetcad}
1186  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
1187
1188 MACRO {ipl} {"Information Processing Letters"}
1189
1190 MACRO {jacm} {"Journal of the ACM"}
1191
1192 MACRO {jcss} {"Journal of Computer and System Sciences"}
1193
1194 MACRO {scp} {"Science of Computer Programming"}
1195
1196 MACRO {sicomp} {"SIAM Journal on Computing"}
1197
1198 MACRO {tocs} {"ACM Transactions on Computer Systems"}
1199
1200 MACRO {tods} {"ACM Transactions on Database Systems"}
1201
1202 MACRO {tog} {"ACM Transactions on Graphics"}
1203
1204 MACRO {toms} {"ACM Transactions on Mathematical Software"}
1205
1206 MACRO {toois} {"ACM Transactions on Office Information Systems"}
1207
1208 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
1209
1210 MACRO {tcs} {"Theoretical Computer Science"}
1211
1212 READ
1213
1214 FUNCTION {sortify}
1215 { purify$
1216   "l" change.case$
1217 }
1218
1219 INTEGERS { len }
1220
1221 FUNCTION {chop.word}
1222 { 's :=
1223   'len :=
1224   s #1 len substring$ =
1225     { s len #1 + global.max$ substring$ }
1226     's
1227   if$
1228 }
1229
1230 FUNCTION {sort.format.names}
1231 { 's :=
1232   #1 'nameptr :=
1233   ""
1234   s num.names$ 'numnames :=
1235   numnames 'namesleft :=
1236     { namesleft #0 > }
1237     { nameptr #1 >
1238         { "   " * }
1239         'skip$
1240       if$
1241       s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ 't :=
1242       nameptr numnames = t "others" = and
1243         { "et al" * }
1244         { t sortify * }
1245       if$
1246       nameptr #1 + 'nameptr :=
1247       namesleft #1 - 'namesleft :=
1248     }
1249   while$
1250 }
1251
1252 FUNCTION {sort.format.title}
1253 { 't :=
1254   "A " #2
1255     "An " #3
1256       "The " #4 t chop.word
1257     chop.word
1258   chop.word
1259   sortify
1260   #1 global.max$ substring$
1261 }
1262
1263 FUNCTION {author.sort}
1264 { author empty$
1265     { key empty$
1266         { "to sort, need author or key in " cite$ * warning$
1267           ""
1268         }
1269         { key sortify }
1270       if$
1271     }
1272     { author sort.format.names }
1273   if$
1274 }
1275
1276 FUNCTION {author.editor.sort}
1277 { author empty$
1278     { editor empty$
1279         { key empty$
1280             { "to sort, need author, editor, or key in " cite$ * warning$
1281               ""
1282             }
1283             { key sortify }
1284           if$
1285         }
1286         { editor sort.format.names }
1287       if$
1288     }
1289     { author sort.format.names }
1290   if$
1291 }
1292
1293 FUNCTION {author.organization.sort}
1294 { author empty$
1295     { organization empty$
1296         { key empty$
1297             { "to sort, need author, organization, or key in " cite$ * warning$
1298               ""
1299             }
1300             { key sortify }
1301           if$
1302         }
1303         { "The " #4 organization chop.word sortify }
1304       if$
1305     }
1306     { author sort.format.names }
1307   if$
1308 }
1309
1310 FUNCTION {editor.organization.sort}
1311 { editor empty$
1312     { organization empty$
1313         { key empty$
1314             { "to sort, need editor, organization, or key in " cite$ * warning$
1315               ""
1316             }
1317             { key sortify }
1318           if$
1319         }
1320         { "The " #4 organization chop.word sortify }
1321       if$
1322     }
1323     { editor sort.format.names }
1324   if$
1325 }
1326
1327 FUNCTION {presort}
1328 { type$ "book" =
1329   type$ "inbook" =
1330   or
1331     'author.editor.sort
1332     { type$ "proceedings" =
1333         'editor.organization.sort
1334         { type$ "manual" =
1335             'author.organization.sort
1336             'author.sort
1337           if$
1338         }
1339       if$
1340     }
1341   if$
1342   duplicate$ empty$ 'skip$ { "    " * } if$
1343   key empty$
1344     { title field.or.null sort.format.title * "    " * booktitle field.or.null sort.format.title * }
1345     { key sortify * }
1346   if$
1347   "    "
1348   *
1349   year field.or.null sortify
1350   *
1351   #1 entry.max$ substring$
1352   'sort.key$ :=
1353 }
1354
1355 ITERATE {presort}
1356
1357 SORT
1358
1359 STRINGS {a b}
1360 INTEGERS {i j}
1361
1362 FUNCTION {init.vars}
1363 { #0 int.to.chr$ 'a :=
1364   #0 int.to.chr$ 'b :=
1365   #0 'i :=
1366   #0 'j :=
1367 }
1368
1369 FUNCTION {forward.author.dup.check}
1370 {
1371   url empty$ 'skip$ { url.used #1 + 'url.used := } if$
1372   crossref empty$ 'skip$ { citen.used #1 + 'citen.used := } if$
1373   author empty$
1374     { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
1375     { author 'a := }
1376   if$
1377   %'a :=
1378   a empty$
1379     'skip$
1380     { b "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$
1381       a "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1382         { #1 'author.duplicate := }
1383         { #0 'author.duplicate := }
1384       if$
1385       a 'b :=
1386     }
1387   if$
1388 }
1389
1390 FUNCTION {forward.author.share.check}
1391 %
1392 % Pass through all entries, comparing current author to last one.
1393 %
1394 { author.duplicate author empty$ or
1395   { author.duplicate { i 'author.shared := }{} if$}
1396   { b "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$
1397     author field.or.null "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1398     { author.flast 'author.shared := }
1399     { b "{vv~}{ll}" format.names.custom purify$
1400       author field.or.null "{vv~}{ll}" format.names.custom purify$ =
1401       { author.last 'author.shared := }
1402       { author.different 'author.shared := }
1403       if$
1404     }
1405     if$
1406     author.shared 'i :=
1407     author field.or.null 'b :=
1408   }
1409   if$
1410 }
1411
1412 FUNCTION {reverse.author}
1413
1414   author.duplicate
1415   { author.shared i <
1416       { i 'author.shared := }
1417       {}
1418     if$
1419   }
1420   { author.shared i <
1421       { author.shared i 'author.shared := 'i := }
1422       { author.shared 'i := }
1423     if$
1424   }
1425   if$
1426   j #1 = author.duplicate not and { #2 'author.duplicate := } {} if$
1427   author.duplicate 'j :=
1428 }
1429
1430 EXECUTE {init.consts}
1431
1432 EXECUTE {init.vars}
1433 ITERATE {forward.author.dup.check}
1434
1435 EXECUTE {init.vars}
1436 ITERATE {forward.author.share.check}
1437
1438 EXECUTE {init.vars}
1439 REVERSE {reverse.author}
1440
1441 %INTEGERS { number.label longest.label.width }
1442
1443 %FUNCTION {initialize.longest.label}
1444 %{ "" 'longest.label :=
1445 %  #1 'number.label :=
1446 %  #0 'longest.label.width :=
1447 %}
1448
1449 %FUNCTION {longest.label.pass}
1450 %{ number.label int.to.str$ 'label :=
1451 %  number.label #1 + 'number.label :=
1452 %  label width$ longest.label.width >
1453 %    { label 'longest.label :=
1454 %      label width$ 'longest.label.width :=
1455 %    }
1456 %    'skip$
1457 %  if$
1458 %}
1459
1460 %EXECUTE {initialize.longest.label}
1461
1462 %ITERATE {longest.label.pass}
1463
1464 FUNCTION {begin.bib}
1465 {
1466   citen.used
1467     { "\ifx\undefined\citeN\let\citeN\cite\fi" write$ newline$ }
1468     'skip$
1469   if$
1470   url.used
1471     { "\ifx\undefined\url\let\url\relax\fi" write$ newline$ }
1472     'skip$
1473   if$
1474   preamble$ empty$
1475     'skip$
1476     { preamble$ write$ newline$ }
1477   if$
1478   "\begin{thebibliography}{\rule{.5in}{0pt}}" write$ newline$
1479 }
1480
1481 EXECUTE {begin.bib}
1482
1483 ITERATE {call.type$}
1484
1485 FUNCTION {end.bib}
1486 { newline$
1487   "\end{thebibliography}" write$ newline$
1488 }
1489
1490 EXECUTE {end.bib}