Debian Codegraph @

texmf-dist/bibtex/bst/sort-by-letters/alpha-letters.bst

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