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