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