Debian Codegraph @

texmf-dist/bibtex/bst/utbmciad-report/utbmciad.bst

raw
1 % BibTeX `apalike' bibliography style (version 0.99a, 8-Dec-10), adapted from
2 % the `alpha' style, version 0.99a; for BibTeX version 0.99a.
3 %
4 % Copyright (C) 1988, 2010 Oren Patashnik.
5 % Copyright (C) 2014-2026 Stephane Galland.
6 % Unlimited copying and redistribution of this file are permitted as long as
7 % it is unmodified. Modifications (and redistribution of modified versions)
8 % are also permitted, but only if the resulting file is renamed.
9 %
10 % Differences between this style and `alpha' are generally heralded by a `%'.
11 % The file btxbst.doc has the documentation for alpha.bst.
12 %
13 % This style should be used with the `apalike' LaTeX style (apalike.sty).
14 % \cite's come out like "(Jones, 1986)" in the text but there are no labels
15 % in the bibliography, and something like "(1986)" comes out immediately
16 % after the author. Author (and editor) names appear as last name, comma,
17 % initials. A `year' field is required for every entry, and so is either
18 % an author (or in some cases, an editor) field or a key field.
19 %
20 % Editorial note:
21 % Many journals require a style like `apalike', but I strongly, strongly,
22 % strongly recommend that you not use it if you have a choice---use something
23 % like `plain' instead. Mary-Claire van Leunen (A Handbook for Scholars,
24 % Knopf, 1979) argues convincingly that a style like `plain' encourages better
25 % writing than one like `apalike'. Furthermore the strongest arguments for
26 % using an author-date style like `apalike'---that it's "the most practical"
27 % (The Chicago Manual of Style, University of Chicago Press, thirteenth
28 % edition, 1982, pages 400--401)---fall flat on their face with the new
29 % computer-typesetting technology. For instance page 401 anachronistically
30 % states "The chief disadvantage of [a style like `plain'] is that additions
31 % or deletions cannot be made after the manuscript is typed without changing
32 % numbers in both text references and list." LaTeX sidesteps the disadvantage.
33 %
34 % History:
35 % 15-sep-86 (OP) Original version by Oren Patashnik, ideas from Susan King.
36 % 10-nov-86 (OP) Truncated the sort.key$ string to the correct length
37 % in bib.sort.order to eliminate error message.
38 % 24-jan-88 (OP) Updated for BibTeX version 0.99a, from alpha.bst 0.99a;
39 % apalike now sorts by author, then year, then title;
40 % THIS `apalike' VERSION DOES NOT WORK WITH BIBTEX 0.98i.
41 % 8-dec-10 (OP) Still version 0.99a, as the code itself was unchanged;
42 % this release clarified the license.
43 % 07/09/14 (SG) Adapted for PHD thesis.
44
45 ENTRY
46 { address
47 author
48 booktitle
49 chapter
50 edition
51 editor
52 howpublished
53 institution
54 journal
55 key
56 % month not used in apalike
57 note
58 number
59 organization
60 pages
61 publisher
62 school
63 series
64 title
65 type
66 volume
67 year
68 }
69 {}
70 { label extra.label sort.label }
71
72 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
73
74 FUNCTION {init.state.consts}
75 { #0 'before.all :=
76 #1 'mid.sentence :=
77 #2 'after.sentence :=
78 #3 'after.block :=
79 }
80
81 STRINGS { s t nt }
82
83 FUNCTION {output.nonnull}
84 { 's :=
85 output.state mid.sentence =
86 { ", " * write$ }
87 { output.state after.block =
88 { add.period$ write$
89 newline$
90 "\newblock " write$
91 }
92 { output.state before.all =
93 'write$
94 { add.period$ " " * write$ }
95 if$
96 }
97 if$
98 mid.sentence 'output.state :=
99 }
100 if$
101 s
102 }
103
104 FUNCTION {output}
105 { duplicate$ empty$
106 'pop$
107 'output.nonnull
108 if$
109 }
110
111 FUNCTION {output.check}
112 { 't :=
113 duplicate$ empty$
114 { pop$ "empty " t * " in " * cite$ * warning$ }
115 'output.nonnull
116 if$
117 }
118
119 % apalike needs this function because
120 % the year has special punctuation;
121 % apalike ignores the month
122 FUNCTION {output.year.check}
123 { year empty$
124 { "empty year in " cite$ * warning$ }
125 { write$
126 " (" year * extra.label * ")" *
127 mid.sentence 'output.state :=
128 }
129 if$
130 }
131
132 FUNCTION {output.bibitem}
133 { newline$
134 "\bibitem[" write$
135 label write$
136 "]{" write$
137 cite$ write$
138 "}" write$
139 newline$
140 ""
141 before.all 'output.state :=
142 }
143
144 FUNCTION {fin.entry}
145 { add.period$
146 write$
147 newline$
148 }
149
150 FUNCTION {new.block}
151 { output.state before.all =
152 'skip$
153 { after.block 'output.state := }
154 if$
155 }
156
157 FUNCTION {new.sentence}
158 { output.state after.block =
159 'skip$
160 { output.state before.all =
161 'skip$
162 { after.sentence 'output.state := }
163 if$
164 }
165 if$
166 }
167
168 FUNCTION {not}
169 { { #0 }
170 { #1 }
171 if$
172 }
173
174 FUNCTION {and}
175 { 'skip$
176 { pop$ #0 }
177 if$
178 }
179
180 FUNCTION {or}
181 { { pop$ #1 }
182 'skip$
183 if$
184 }
185
186 FUNCTION {new.block.checkb}
187 { empty$
188 swap$ empty$
189 and
190 'skip$
191 'new.block
192 if$
193 }
194
195 FUNCTION {field.or.null}
196 { duplicate$ empty$
197 { pop$ "" }
198 'skip$
199 if$
200 }
201
202 FUNCTION {emphasize}
203 { duplicate$ empty$
204 { pop$ "" }
205 { "\utbmciadbibemph{" swap$ * "}" * }
206 if$
207 }
208
209 INTEGERS { nameptr namesleft numnames }
210
211 FUNCTION {format.names}
212 { 's :=
213 #1 'nameptr :=
214 s num.names$ 'numnames :=
215 numnames 'namesleft :=
216 { namesleft #0 > }
217 { s nameptr "{ll}" format.name$
218 purify$ "l" change.case$ 'nt :=
219 s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=
220 "\underlineifauthor{" nt * "}{" * t * "}" * 't :=
221 nameptr #1 >
222 { namesleft #1 >
223 { ", " * t * }
224 { t "others" =
225 { ", \utbmciadbiband" * }
226 { ", \utbmciadbiband" * t * }
227 if$
228 }
229 if$
230 }
231 't
232 if$
233 nameptr #1 + 'nameptr :=
234 namesleft #1 - 'namesleft :=
235 }
236 while$
237 }
238
239 FUNCTION {format.authors}
240 { author empty$
241 { "" }
242 { author format.names }
243 if$
244 }
245
246 FUNCTION {format.key} % this function is just for apalike
247 { empty$
248 { key field.or.null }
249 { "" }
250 if$
251 }
252
253 FUNCTION {format.editors}
254 { editor empty$
255 { "" }
256 { editor format.names
257 editor num.names$ #1 >
258 { ", \utbmciadbibeditors" * }
259 { ", \utbmciadbibeditor" * }
260 if$
261 }
262 if$
263 }
264
265 FUNCTION {format.title}
266 { title empty$
267 { "" }
268 { "\utbmciadbibEmph{" title "t" change.case$ * "}" * }
269 if$
270 }
271
272 FUNCTION {n.dashify}
273 { 't :=
274 ""
275 { t empty$ not }
276 { t #1 #1 substring$ "-" =
277 { t #1 #2 substring$ "--" = not
278 { "--" *
279 t #2 global.max$ substring$ 't :=
280 }
281 { { t #1 #1 substring$ "-" = }
282 { "-" *
283 t #2 global.max$ substring$ 't :=
284 }
285 while$
286 }
287 if$
288 }
289 { t #1 #1 substring$ *
290 t #2 global.max$ substring$ 't :=
291 }
292 if$
293 }
294 while$
295 }
296
297 FUNCTION {format.btitle}
298 { "\utbmciadbibEmph{" title * "}" *
299 }
300
301 FUNCTION {tie.or.space.connect}
302 { duplicate$ text.length$ #3 <
303 { "~" }
304 { " " }
305 if$
306 swap$ * *
307 }
308
309 FUNCTION {either.or.check}
310 { empty$
311 'pop$
312 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
313 if$
314 }
315
316 FUNCTION {format.bvolume}
317 { volume empty$
318 { "" }
319 { "\utbmciadbibvolume" volume tie.or.space.connect
320 series empty$
321 'skip$
322 { " \utbmciadbibof " * series emphasize * }
323 if$
324 "\utbmciadbibvolumenumber" number either.or.check
325 }
326 if$
327 }
328
329 FUNCTION {format.number.series}
330 { volume empty$
331 { number empty$
332 { series field.or.null }
333 { output.state mid.sentence =
334 { "\utbmciadbibnumber" }
335 { "\utbmciadbibNumber" }
336 if$
337 number tie.or.space.connect
338 series empty$
339 { "there's a number but no series in " cite$ * warning$ }
340 { " \utbmciadbibin " * series * }
341 if$
342 }
343 if$
344 }
345 { "" }
346 if$
347 }
348
349 FUNCTION {format.edition}
350 { edition empty$
351 { "" }
352 { output.state mid.sentence =
353 { edition "l" change.case$ " \utbmciadbibedition" * }
354 { edition "t" change.case$ " \utbmciadbibedition" * }
355 if$
356 }
357 if$
358 }
359
360 INTEGERS { multiresult }
361
362 FUNCTION {multi.page.check}
363 { 't :=
364 #0 'multiresult :=
365 { multiresult not
366 t empty$ not
367 and
368 }
369 { t #1 #1 substring$
370 duplicate$ "-" =
371 swap$ duplicate$ "," =
372 swap$ "+" =
373 or or
374 { #1 'multiresult := }
375 { t #2 global.max$ substring$ 't := }
376 if$
377 }
378 while$
379 multiresult
380 }
381
382 FUNCTION {format.pages}
383 { pages empty$
384 { "" }
385 { pages multi.page.check
386 { "\utbmciadbibpages" pages n.dashify tie.or.space.connect }
387 { "\utbmciadbibpage" pages tie.or.space.connect }
388 if$
389 }
390 if$
391 }
392
393 FUNCTION {format.vol.num.pages}
394 { volume field.or.null
395 number empty$
396 'skip$
397 { "(" number * ")" * *
398 volume empty$
399 { "there's a number but no volume in " cite$ * warning$ }
400 'skip$
401 if$
402 }
403 if$
404 pages empty$
405 'skip$
406 { duplicate$ empty$
407 { pop$ format.pages }
408 { ":" * pages n.dashify * }
409 if$
410 }
411 if$
412 }
413
414 FUNCTION {format.chapter.pages}
415 { chapter empty$
416 'format.pages
417 { type empty$
418 { "\utbmciadbibchapter" }
419 { type "l" change.case$ }
420 if$
421 chapter tie.or.space.connect
422 pages empty$
423 'skip$
424 { ", " * format.pages * }
425 if$
426 }
427 if$
428 }
429
430 FUNCTION {format.in.ed.booktitle}
431 { booktitle empty$
432 { "" }
433 { editor empty$
434 { "\utbmciadbibIn " booktitle emphasize * }
435 { "\utbmciadbibIn " format.editors * ", " * booktitle emphasize * }
436 if$
437 }
438 if$
439 }
440
441 FUNCTION {format.thesis.type}
442 { type empty$
443 'skip$
444 { pop$
445 type "t" change.case$
446 }
447 if$
448 }
449
450 FUNCTION {format.tr.number}
451 { type empty$
452 { "\utbmciadbibtechnicalreport" }
453 'type
454 if$
455 number empty$
456 { "t" change.case$ }
457 { number tie.or.space.connect }
458 if$
459 }
460
461 FUNCTION {format.article.crossref}
462 { "\utbmciadbibIn\ " % this is for apalike
463 " \cite{" * crossref * "}" *
464 }
465
466 FUNCTION {format.book.crossref}
467 { volume empty$
468 { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
469 "\utbmciadbibIn\ "
470 }
471 { "\utbmciadbibVolume" volume tie.or.space.connect
472 " \utbmciadbibof\ " *
473 }
474 if$
475 "\cite{" * crossref * "}" * % this is for apalike
476 }
477
478 FUNCTION {format.incoll.inproc.crossref}
479 { "\utbmciadbibIn" % this is for apalike
480 " \cite{" * crossref * "}" *
481 }
482
483 FUNCTION {article}
484 { output.bibitem
485 format.authors "author" output.check
486 author format.key output % special for
487 output.year.check % apalike
488 new.block
489 format.title "title" output.check
490 new.block
491 crossref missing$
492 { journal emphasize "journal" output.check
493 format.vol.num.pages output
494 }
495 { format.article.crossref output.nonnull
496 format.pages output
497 }
498 if$
499 new.block
500 note output
501 fin.entry
502 }
503
504 FUNCTION {book}
505 { output.bibitem
506 author empty$
507 { format.editors "author and editor" output.check
508 editor format.key output
509 }
510 { format.authors output.nonnull
511 crossref missing$
512 { "author and editor" editor either.or.check }
513 'skip$
514 if$
515 }
516 if$
517 output.year.check % special for apalike
518 new.block
519 format.btitle "title" output.check
520 crossref missing$
521 { format.bvolume output
522 new.block
523 format.number.series output
524 new.sentence
525 publisher "publisher" output.check
526 address output
527 }
528 { new.block
529 format.book.crossref output.nonnull
530 }
531 if$
532 format.edition output
533 new.block
534 note output
535 fin.entry
536 }
537
538 FUNCTION {booklet}
539 { output.bibitem
540 format.authors output
541 author format.key output % special for
542 output.year.check % apalike
543 new.block
544 format.title "title" output.check
545 new.block
546 howpublished output
547 address output
548 new.block
549 note output
550 fin.entry
551 }
552
553 FUNCTION {inbook}
554 { output.bibitem
555 author empty$
556 { format.editors "author and editor" output.check
557 editor format.key output
558 }
559 { format.authors output.nonnull
560 crossref missing$
561 { "author and editor" editor either.or.check }
562 'skip$
563 if$
564 }
565 if$
566 output.year.check % special for apalike
567 new.block
568 format.btitle "title" output.check
569 crossref missing$
570 { format.bvolume output
571 format.chapter.pages "chapter and pages" output.check
572 new.block
573 format.number.series output
574 new.sentence
575 publisher "publisher" output.check
576 address output
577 }
578 { format.chapter.pages "chapter and pages" output.check
579 new.block
580 format.book.crossref output.nonnull
581 }
582 if$
583 format.edition output
584 new.block
585 note output
586 fin.entry
587 }
588
589 FUNCTION {incollection}
590 { output.bibitem
591 format.authors "author" output.check
592 author format.key output % special for
593 output.year.check % apalike
594 new.block
595 format.title "title" output.check
596 new.block
597 crossref missing$
598 { format.in.ed.booktitle "booktitle" output.check
599 format.bvolume output
600 format.number.series output
601 format.chapter.pages output
602 new.sentence
603 publisher "publisher" output.check
604 address output
605 format.edition output
606 }
607 { format.incoll.inproc.crossref output.nonnull
608 format.chapter.pages output
609 }
610 if$
611 new.block
612 note output
613 fin.entry
614 }
615
616 FUNCTION {inproceedings}
617 { output.bibitem
618 format.authors "author" output.check
619 author format.key output % special for
620 output.year.check % apalike
621 new.block
622 format.title "title" output.check
623 new.block
624 crossref missing$
625 { format.in.ed.booktitle "booktitle" output.check
626 format.bvolume output
627 format.number.series output
628 format.pages output
629 address output % for apalike
630 new.sentence % there's no year
631 organization output % here so things
632 publisher output % are simpler
633 }
634 { format.incoll.inproc.crossref output.nonnull
635 format.pages output
636 }
637 if$
638 new.block
639 note output
640 fin.entry
641 }
642
643 FUNCTION {conference} { inproceedings }
644
645 FUNCTION {manual}
646 { output.bibitem
647 format.authors output
648 author format.key output % special for
649 output.year.check % apalike
650 new.block
651 format.btitle "title" output.check
652 organization address new.block.checkb
653 organization output
654 address output
655 format.edition output
656 new.block
657 note output
658 fin.entry
659 }
660
661 FUNCTION {mastersthesis}
662 { output.bibitem
663 format.authors "author" output.check
664 author format.key output % special for
665 output.year.check % apalike
666 new.block
667 format.title "title" output.check
668 new.block
669 "Master's thesis" format.thesis.type output.nonnull
670 school "school" output.check
671 address output
672 new.block
673 note output
674 fin.entry
675 }
676
677 FUNCTION {misc}
678 { output.bibitem
679 format.authors output
680 author format.key output % special for
681 output.year.check % apalike
682 new.block
683 format.title output
684 new.block
685 howpublished output
686 new.block
687 note output
688 fin.entry
689 }
690
691 FUNCTION {phdthesis}
692 { output.bibitem
693 format.authors "author" output.check
694 author format.key output % special for
695 output.year.check % apalike
696 new.block
697 format.btitle "title" output.check
698 new.block
699 "PhD thesis" format.thesis.type output.nonnull
700 school "school" output.check
701 address output
702 new.block
703 note output
704 fin.entry
705 }
706
707 FUNCTION {proceedings}
708 { output.bibitem
709 format.editors output
710 editor format.key output % special for
711 output.year.check % apalike
712 new.block
713 format.btitle "title" output.check
714 format.bvolume output
715 format.number.series output
716 address output % for apalike
717 new.sentence % we always output
718 organization output % a nonempty organization
719 publisher output % here
720 new.block
721 note output
722 fin.entry
723 }
724
725 FUNCTION {techreport}
726 { output.bibitem
727 format.authors "author" output.check
728 author format.key output % special for
729 output.year.check % apalike
730 new.block
731 format.title "title" output.check
732 new.block
733 format.tr.number output.nonnull
734 institution "institution" output.check
735 address output
736 new.block
737 note output
738 fin.entry
739 }
740
741 FUNCTION {unpublished}
742 { output.bibitem
743 format.authors "author" output.check
744 author format.key output % special for
745 output.year.check % apalike
746 new.block
747 format.title "title" output.check
748 new.block
749 note "note" output.check
750 fin.entry
751 }
752
753 FUNCTION {default.type} { misc }
754
755 MACRO {jan} {"\utbmciadbibJanuary"}
756
757 MACRO {feb} {"\utbmciadbibFebruary"}
758
759 MACRO {mar} {"\utbmciadbibMarch"}
760
761 MACRO {apr} {"\utbmciadbibApril"}
762
763 MACRO {may} {"\utbmciadbibMay"}
764
765 MACRO {jun} {"\utbmciadbibJune"}
766
767 MACRO {jul} {"\utbmciadbibJuly"}
768
769 MACRO {aug} {"\utbmciadbibAugust"}
770
771 MACRO {sep} {"\utbmciadbibSeptember"}
772
773 MACRO {oct} {"\utbmciadbibOctober"}
774
775 MACRO {nov} {"\utbmciadbibNovember"}
776
777 MACRO {dec} {"\utbmciadbibDecember"}
778
779 MACRO {acmcs} {"ACM Computing Surveys"}
780
781 MACRO {acta} {"Acta Informatica"}
782
783 MACRO {cacm} {"Communications of the ACM"}
784
785 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
786
787 MACRO {ibmsj} {"IBM Systems Journal"}
788
789 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
790
791 MACRO {ieeetc} {"IEEE Transactions on Computers"}
792
793 MACRO {ieeetcad}
794 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
795
796 MACRO {ipl} {"Information Processing Letters"}
797
798 MACRO {jacm} {"Journal of the ACM"}
799
800 MACRO {jcss} {"Journal of Computer and System Sciences"}
801
802 MACRO {scp} {"Science of Computer Programming"}
803
804 MACRO {sicomp} {"SIAM Journal on Computing"}
805
806 MACRO {tocs} {"ACM Transactions on Computer Systems"}
807
808 MACRO {tods} {"ACM Transactions on Database Systems"}
809
810 MACRO {tog} {"ACM Transactions on Graphics"}
811
812 MACRO {toms} {"ACM Transactions on Mathematical Software"}
813
814 MACRO {toois} {"ACM Transactions on Office Information Systems"}
815
816 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
817
818 MACRO {tcs} {"Theoretical Computer Science"}
819
820 READ
821
822 FUNCTION {sortify}
823 { purify$
824 "l" change.case$
825 }
826
827 INTEGERS { len }
828
829 FUNCTION {chop.word}
830 { 's :=
831 'len :=
832 s #1 len substring$ =
833 { s len #1 + global.max$ substring$ }
834 's
835 if$
836 }
837
838 % There are three apalike cases: one person (Jones),
839 % two (Jones and de~Bruijn), and more (Jones et~al.).
840 % This function is much like format.crossref.editors.
841 %
842 % Note that if more than one name exist, the "et al." is output
843 FUNCTION {format.lab.names}
844 { 's :=
845 s #1 "{vv~}{ll}" format.name$
846 s num.names$ duplicate$
847 #1 >
848 { pop$ " et~al." * }
849 { #2 <
850 'skip$
851 { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
852 { " \utbmciadbibetal" * }
853 { " \utbmciadbiband\ " * s #2 "{vv~}{ll}" format.name$ * }
854 if$
855 }
856 if$
857 }
858 if$
859 }
860
861 FUNCTION {author.key.label}
862 { author empty$
863 { key empty$
864 { cite$ #1 #3 substring$ }
865 'key % apalike uses the whole key
866 if$
867 }
868 { author format.lab.names }
869 if$
870 }
871
872 FUNCTION {author.editor.key.label}
873 { author empty$
874 { editor empty$
875 { key empty$
876 { cite$ #1 #3 substring$ }
877 'key % apalike uses the whole key
878 if$
879 }
880 { editor format.lab.names }
881 if$
882 }
883 { author format.lab.names }
884 if$
885 }
886
887 FUNCTION {editor.key.label}
888 { editor empty$
889 { key empty$
890 { cite$ #1 #3 substring$ }
891 'key % apalike uses the whole key, no organization
892 if$
893 }
894 { editor format.lab.names }
895 if$
896 }
897
898 FUNCTION {calc.label}
899 { type$ "book" =
900 type$ "inbook" =
901 or
902 'author.editor.key.label
903 { type$ "proceedings" =
904 'editor.key.label % apalike ignores organization
905 'author.key.label % for labeling and sorting
906 if$
907 }
908 if$
909 ", " % these three lines are
910 * % for apalike, which
911 year field.or.null purify$ #-1 #4 substring$ % uses all four digits
912 *
913 'label :=
914 }
915
916 FUNCTION {sort.format.names}
917 { 's :=
918 #1 'nameptr :=
919 ""
920 s num.names$ 'numnames :=
921 numnames 'namesleft :=
922 { namesleft #0 > }
923 { nameptr #1 >
924 { " " * }
925 'skip$
926 if$ % apalike uses initials
927 s nameptr "{vv{ } }{ll{ }}{ f{ }}{ jj{ }}" format.name$ 't := % <= here
928 nameptr numnames = t "others" = and
929 { "et al" * }
930 { t sortify * }
931 if$
932 nameptr #1 + 'nameptr :=
933 namesleft #1 - 'namesleft :=
934 }
935 while$
936 }
937
938 FUNCTION {sort.format.title}
939 { 't :=
940 "A " #2
941 "An " #3
942 "The " #4 t chop.word
943 chop.word
944 chop.word
945 sortify
946 #1 global.max$ substring$
947 }
948
949 FUNCTION {author.sort}
950 { author empty$
951 { key empty$
952 { "to sort, need author or key in " cite$ * warning$
953 ""
954 }
955 { key sortify }
956 if$
957 }
958 { author sort.format.names }
959 if$
960 }
961
962 FUNCTION {author.editor.sort}
963 { author empty$
964 { editor empty$
965 { key empty$
966 { "to sort, need author, editor, or key in " cite$ * warning$
967 ""
968 }
969 { key sortify }
970 if$
971 }
972 { editor sort.format.names }
973 if$
974 }
975 { author sort.format.names }
976 if$
977 }
978
979 FUNCTION {editor.sort}
980 { editor empty$
981 { key empty$
982 { "to sort, need editor or key in " cite$ * warning$
983 ""
984 }
985 { key sortify }
986 if$
987 }
988 { editor sort.format.names }
989 if$
990 }
991
992 % apalike uses two sorting passes; the first one sets the
993 % labels so that the `a's, `b's, etc. can be computed;
994 % the second pass puts the references in "correct" order.
995 % The presort function is for the first pass. It computes
996 % label, sort.label, and title, and then concatenates.
997 FUNCTION {presort}
998 { calc.label
999 label sortify
1000 " "
1001 *
1002 type$ "book" =
1003 type$ "inbook" =
1004 or
1005 'author.editor.sort
1006 { type$ "proceedings" =
1007 'editor.sort
1008 'author.sort
1009 if$
1010 }
1011 if$
1012 #1 entry.max$ substring$ % for
1013 'sort.label := % apalike
1014 sort.label % style
1015 *
1016 " "
1017 *
1018 title field.or.null
1019 sort.format.title
1020 *
1021 #1 entry.max$ substring$
1022 'sort.key$ :=
1023 }
1024
1025 ITERATE {presort}
1026
1027 SORT % by label, sort.label, title---for final label calculation
1028
1029 STRINGS { last.label next.extra } % apalike labels are only for the text;
1030
1031 INTEGERS { last.extra.num } % there are none in the bibliography
1032
1033 FUNCTION {initialize.extra.label.stuff} % and hence there is no `longest.label'
1034 { #0 int.to.chr$ 'last.label :=
1035 "" 'next.extra :=
1036 #0 'last.extra.num :=
1037 }
1038
1039 FUNCTION {forward.pass}
1040 { last.label label =
1041 { last.extra.num #1 + 'last.extra.num :=
1042 last.extra.num int.to.chr$ 'extra.label :=
1043 }
1044 { "a" chr.to.int$ 'last.extra.num :=
1045 "" 'extra.label :=
1046 label 'last.label :=
1047 }
1048 if$
1049 }
1050
1051 FUNCTION {reverse.pass}
1052 { next.extra "b" =
1053 { "a" 'extra.label := }
1054 'skip$
1055 if$
1056 label extra.label * 'label :=
1057 extra.label 'next.extra :=
1058 }
1059
1060 EXECUTE {initialize.extra.label.stuff}
1061
1062 ITERATE {forward.pass}
1063
1064 REVERSE {reverse.pass}
1065
1066 % Now that the label is right we sort for real,
1067 % on sort.label then year then title. This is
1068 % for the second sorting pass.
1069 FUNCTION {bib.sort.order}
1070 { sort.label
1071 " "
1072 *
1073 year field.or.null sortify
1074 *
1075 " "
1076 *
1077 title field.or.null
1078 sort.format.title
1079 *
1080 #1 entry.max$ substring$
1081 'sort.key$ :=
1082 }
1083
1084 ITERATE {bib.sort.order}
1085
1086 SORT % by sort.label, year, title---giving final bibliography order
1087
1088 FUNCTION {begin.bib}
1089 { preamble$ empty$ % no \etalchar in apalike
1090 'skip$
1091 { preamble$ write$ newline$ }
1092 if$
1093 "\begin{thebibliography}{}" write$ newline$ % no labels in apalike
1094 }
1095
1096 EXECUTE {begin.bib}
1097
1098 EXECUTE {init.state.consts}
1099
1100 ITERATE {call.type$}
1101
1102 FUNCTION {end.bib}
1103 { newline$
1104 "\end{thebibliography}" write$ newline$
1105 }
1106
1107 EXECUTE {end.bib}