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