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