Updated index
[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 citealp.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 'citealp.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     { "\emph{" 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$ { "\citealp" } { "\citealp[" 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$ { "\citealp" } { "\citealp[" 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$ { "\citealp" } { "\citealp[" 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     { cite.title * "( \ \ \ \ \unskip\unskip\unskip\unskip\unskip \unskip)" * }
766     { duplicate$
767       author.shared author.different =
768         { "{vv~}{ll}" format.names.custom 's := }
769         { author.shared author.last =
770             { "{f.~}{vv~}{ll}{, jj}" format.names.custom 's := }
771             { author.shared author.flast =
772                 { "{ff~}{vv~}{ll}{, jj}" format.names.custom 's := }
773                 { "{vv~}{ll}" format.names.custom ", " * cite.title * 's := "WTF" warning$ }
774               if$
775             }
776           if$
777         }
778       if$
779       s
780       "( \ \ \ \ \unskip\unskip\unskip\unskip\unskip " *
781       author.duplicate { cite.title * }{ "\unskip" * } if$
782       ")" * swap$ "{ff~}{vv~}{ll}{, jj}" format.names.custom *
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.block
837   crossref missing$
838     { author empty$ 'skip$ { format.editors.mid output new.block } 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.block } 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.block
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.block
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   url empty$ 'skip$ { url.used #1 + 'url.used := } if$
1373   crossref empty$ 'skip$ { citealp.used #1 + 'citealp.used := } if$
1374   author empty$
1375     { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
1376     { author 'a := }
1377   if$
1378   %'a :=
1379   a empty$
1380     'skip$
1381     { b "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$
1382       a "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1383         { #1 'author.duplicate := }
1384         { #0 'author.duplicate := }
1385       if$
1386       a 'b :=
1387     }
1388   if$
1389 }
1390
1391 FUNCTION {forward.author.share.check}
1392 %
1393 % Pass through all entries, comparing current author to last one.
1394 %
1395 { author.duplicate author empty$ or
1396   { author.duplicate { i 'author.shared := }{} if$}
1397   { b "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$
1398     author field.or.null "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1399     { author.flast 'author.shared := }
1400     { b "{vv~}{ll}" format.names.custom purify$
1401       author field.or.null "{vv~}{ll}" format.names.custom purify$ =
1402       { author.last 'author.shared := }
1403       { author.different 'author.shared := }
1404       if$
1405     }
1406     if$
1407     author.shared 'i :=
1408     author field.or.null 'b :=
1409   }
1410   if$
1411 }
1412
1413 FUNCTION {reverse.author}
1414
1415   author.duplicate
1416   { author.shared i <
1417       { i 'author.shared := }
1418       {}
1419     if$
1420   }
1421   { author.shared i <
1422       { author.shared i 'author.shared := 'i := }
1423       { author.shared 'i := }
1424     if$
1425   }
1426   if$
1427   j #1 = author.duplicate not and { #2 'author.duplicate := } {} if$
1428   author.duplicate 'j :=
1429 }
1430
1431 EXECUTE {init.consts}
1432
1433 EXECUTE {init.vars}
1434 ITERATE {forward.author.dup.check}
1435
1436 EXECUTE {init.vars}
1437 ITERATE {forward.author.share.check}
1438
1439 EXECUTE {init.vars}
1440 REVERSE {reverse.author}
1441
1442 %INTEGERS { number.label longest.label.width }
1443
1444 %FUNCTION {initialize.longest.label}
1445 %{ "" 'longest.label :=
1446 %  #1 'number.label :=
1447 %  #0 'longest.label.width :=
1448 %}
1449
1450 %FUNCTION {longest.label.pass}
1451 %{ number.label int.to.str$ 'label :=
1452 %  number.label #1 + 'number.label :=
1453 %  label width$ longest.label.width >
1454 %    { label 'longest.label :=
1455 %      label width$ 'longest.label.width :=
1456 %    }
1457 %    'skip$
1458 %  if$
1459 %}
1460
1461 %EXECUTE {initialize.longest.label}
1462
1463 %ITERATE {longest.label.pass}
1464
1465 FUNCTION {begin.bib}
1466 {
1467   citealp.used
1468     { "\expandafter\ifx\csname citealp\endcsname\relax\let\citealp\cite\fi"
1469       write$ newline$ }
1470     'skip$
1471   if$
1472   url.used
1473     { "\expandafter\ifx\csname citealp\endcsname\relax\url\let\url\relax\fi"
1474       write$ newline$ }
1475     'skip$
1476   if$
1477   preamble$ empty$
1478     'skip$
1479     { preamble$ write$ newline$ }
1480   if$
1481   "\begin{thebibliography}{\rule{.5in}{0pt}}" write$ newline$
1482 }
1483
1484 EXECUTE {begin.bib}
1485
1486 ITERATE {call.type$}
1487
1488 FUNCTION {end.bib}
1489 { newline$
1490   "\end{thebibliography}" write$ newline$
1491 }
1492
1493 EXECUTE {end.bib}