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