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