Debian Codegraph @

texmf-dist/bibtex/bst/urlbst/alphaurl.bst

raw
1 %%% Modification of BibTeX style file /usr/local/texlive/2022/texmf-dist/bibtex/bst/base/alpha.bst
2 %%% ... by urlbst, version 0.9.1 (marked with "% urlbst")
3 %%% See <https://purl.org/nxg/dist/urlbst> and repository <https://heptapod.host/nxg/urlbst>
4 %%% Modifications Copyright 2002–23, Norman Gray,
5 %%% and distributed under the terms of the LPPL; see README for discussion.
6 %%%
7 %%% Added webpage entry type, and url and lastchecked fields.
8 %%% Added eprint support.
9 %%% Added DOI support.
10 %%% Added PUBMED support.
11 %%% Added hyperref support.
12 %%% Original headers follow...
13
14 % BibTeX standard bibliography style `alpha'
15 % Version 0.99b (8-Dec-10 release) for BibTeX versions 0.99a or later.
16 % Copyright (C) 1984, 1985, 1988, 2010 Howard Trickey and Oren Patashnik.
17 % Unlimited copying and redistribution of this file are permitted as long as
18 % it is unmodified. Modifications (and redistribution of modified versions)
19 % are also permitted, but only if the resulting file is renamed to something
20 % besides btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
21 % This restriction helps ensure that all standard styles are identical.
22 % The file btxbst.doc has the documentation for this style.
23
24 ENTRY
25 { address
26 author
27 booktitle
28 chapter
29 edition
30 editor
31 howpublished
32 institution
33 journal
34 key
35 month
36 note
37 number
38 organization
39 pages
40 publisher
41 school
42 series
43 title
44 type
45 volume
46 year
47 eprint % urlbst
48 doi % urlbst
49 pubmed % urlbst
50 url % urlbst
51 lastchecked % urlbst
52 }
53 {}
54 { label extra.label sort.label }
55
56 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
57
58 % urlbst...
59 % urlbst constants and state variables
60 STRINGS { urlintro
61 eprinturl eprintprefix doiprefix doiurl pubmedprefix pubmedurl
62 citedstring onlinestring linktextstring
63 openinlinelink closeinlinelink }
64 INTEGERS { hrefform doiform inlinelinks makeinlinelink
65 addeprints adddoi addpubmed }
66 FUNCTION {init.urlbst.variables}
67 {
68 % The following constants may be adjusted by hand, if desired
69
70 % The first set allow you to enable or disable certain functionality.
71 #1 'addeprints := % 0=no eprints; 1=include eprints
72 #0 'inlinelinks := % 0=URLs explicit; 1=URLs attached to titles
73 #1 'addpubmed := % 0=no PUBMED resolver; 1=include it
74 #1 'adddoi := % 0=no DOI resolver; 1=include it
75 #2 'hrefform := % 0=no crossrefs; 1=hypertex hrefs; 2=hyperref hrefs
76 #0 'doiform := % 0=with href; 1=with \doi{}
77
78 % String constants, which you _might_ want to tweak.
79 "doi:" 'doiprefix := % printed text to introduce DOI
80 "arXiv:" 'eprintprefix := % text prefix printed before eprint ref
81 "PMID:" 'pubmedprefix := % text prefix printed before PUBMED ref
82 "[link]" 'linktextstring := % anonymous link text
83 "cited " 'citedstring := % label in "lastchecked" remark
84 "http://www.ncbi.nlm.nih.gov/pubmed/" 'pubmedurl := % prefix to make URL from PUBMED
85 "https://arxiv.org/abs/" 'eprinturl := % prefix to make URL from eprint ref
86 "online" 'onlinestring := % label that a resource is online
87 "https://doi.org/" 'doiurl := % prefix to make URL from DOI
88 "URL: " 'urlintro := % text prefix before URL
89
90 % The following are internal state variables, not configuration constants,
91 % so they shouldn't be fiddled with.
92 #0 'makeinlinelink := % state variable managed by possibly.setup.inlinelink
93 "" 'openinlinelink := % ditto
94 "" 'closeinlinelink := % ditto
95 }
96 INTEGERS {
97 bracket.state
98 outside.brackets
99 open.brackets
100 within.brackets
101 close.brackets
102 }
103 % ...urlbst to here
104 FUNCTION {init.state.consts}
105 { #0 'outside.brackets := % urlbst...
106 #1 'open.brackets :=
107 #2 'within.brackets :=
108 #3 'close.brackets := % ...urlbst to here
109
110 #0 'before.all :=
111 #1 'mid.sentence :=
112 #2 'after.sentence :=
113 #3 'after.block :=
114 }
115
116 STRINGS { s t }
117
118 % urlbst
119 FUNCTION {output.nonnull.original}
120 { 's :=
121 output.state mid.sentence =
122 { ", " * write$ }
123 { output.state after.block =
124 { add.period$ write$
125 newline$
126 "\newblock " write$
127 }
128 { output.state before.all =
129 'write$
130 { add.period$ " " * write$ }
131 if$
132 }
133 if$
134 mid.sentence 'output.state :=
135 }
136 if$
137 s
138 }
139
140 % urlbst...
141 % Minimal DOI parsing.
142 % Given a DOI on the stack, check whether it starts with 'doiurl' or not.
143 % In either case, leave on the stack first a DOI with, and then a DOI without, the URL prefix.
144 FUNCTION {parse.doi}
145 {
146 #1 doiurl text.length$ substring$
147 doiurl =
148 { doi
149 doi doiurl text.length$ #1 + #999 substring$ }
150 { doiurl doi *
151 doi }
152 if$
153 }
154 % The following three functions are for handling inlinelink. They wrap
155 % a block of text which is potentially output with write$ by multiple
156 % other functions, so we don't know the content a priori.
157 % They communicate between each other using the variables makeinlinelink
158 % (which is true if a link should be made), and closeinlinelink (which holds
159 % the string which should close any current link. They can be called
160 % at any time, but start.inlinelink will be a no-op unless something has
161 % previously set makeinlinelink true, and the two ...end.inlinelink functions
162 % will only do their stuff if start.inlinelink has previously set
163 % closeinlinelink to be non-empty.
164 % (thanks to 'ijvm' for suggested code here)
165 FUNCTION {uand}
166 { 'skip$ { pop$ #0 } if$ } % 'and' (which isn't defined at this point in the file)
167 FUNCTION {possibly.setup.inlinelink}
168 { makeinlinelink hrefform #0 > uand
169 { doi empty$ adddoi uand
170 { pubmed empty$ addpubmed uand
171 { eprint empty$ addeprints uand
172 { url empty$
173 { "" }
174 { url }
175 if$ }
176 { eprinturl eprint * }
177 if$ }
178 { pubmedurl pubmed * }
179 if$ }
180 % { doiurl doi * }
181 { doi empty$
182 { "XXX" }
183 { doi parse.doi pop$ }
184 if$
185 }
186 if$
187 % an appropriately-formatted URL is now on the stack
188 hrefform #1 = % hypertex
189 { "\special {html:<a href=" quote$ * swap$ * quote$ * "> }{" * 'openinlinelink :=
190 "\special {html:</a>}" 'closeinlinelink := }
191 { "\href {" swap$ * "} {" * 'openinlinelink := % hrefform=#2 -- hyperref
192 % the space between "} {" matters: a URL of just the right length can cause "\% newline em"
193 "}" 'closeinlinelink := }
194 if$
195 #0 'makeinlinelink :=
196 }
197 'skip$
198 if$ % makeinlinelink
199 }
200 FUNCTION {add.inlinelink}
201 { openinlinelink empty$
202 'skip$
203 { openinlinelink swap$ * closeinlinelink *
204 "" 'openinlinelink :=
205 }
206 if$
207 }
208 FUNCTION {output.nonnull}
209 { % Save the thing we've been asked to output
210 's :=
211 % If the bracket-state is close.brackets, then add a close-bracket to
212 % what is currently at the top of the stack, and set bracket.state
213 % to outside.brackets
214 bracket.state close.brackets =
215 { "]" *
216 outside.brackets 'bracket.state :=
217 }
218 'skip$
219 if$
220 bracket.state outside.brackets =
221 { % We're outside all brackets -- this is the normal situation.
222 % Write out what's currently at the top of the stack, using the
223 % original output.nonnull function.
224 s
225 add.inlinelink
226 output.nonnull.original % invoke the original output.nonnull
227 }
228 { % Still in brackets. Add open-bracket or (continuation) comma, add the
229 % new text (in s) to the top of the stack, and move to the close-brackets
230 % state, ready for next time (unless inbrackets resets it). If we come
231 % into this branch, then output.state is carefully undisturbed.
232 bracket.state open.brackets =
233 { " [" * }
234 { ", " * } % bracket.state will be within.brackets
235 if$
236 s *
237 close.brackets 'bracket.state :=
238 }
239 if$
240 }
241
242 % Call this function just before adding something which should be presented in
243 % brackets. bracket.state is handled specially within output.nonnull.
244 FUNCTION {inbrackets}
245 { bracket.state close.brackets =
246 { within.brackets 'bracket.state := } % reset the state: not open nor closed
247 { open.brackets 'bracket.state := }
248 if$
249 }
250
251 FUNCTION {format.lastchecked}
252 { lastchecked empty$
253 { "" }
254 { inbrackets citedstring lastchecked * }
255 if$
256 }
257 % ...urlbst to here
258
259 FUNCTION {output}
260 { duplicate$ empty$
261 'pop$
262 'output.nonnull
263 if$
264 }
265
266 FUNCTION {output.check}
267 { 't :=
268 duplicate$ empty$
269 { pop$ "empty " t * " in " * cite$ * warning$ }
270 'output.nonnull
271 if$
272 }
273
274 FUNCTION {output.bibitem.original} % urlbst (renamed from output.bibitem, so it can be wrapped below)
275 { newline$
276 "\bibitem[" write$
277 label write$
278 "]{" write$
279 cite$ write$
280 "}" write$
281 newline$
282 ""
283 before.all 'output.state :=
284 }
285
286 FUNCTION {fin.entry.original} % urlbst (renamed from fin.entry, so it can be wrapped below)
287 { add.period$
288 write$
289 newline$
290 }
291
292 FUNCTION {new.block}
293 { output.state before.all =
294 'skip$
295 { after.block 'output.state := }
296 if$
297 }
298
299 FUNCTION {new.sentence}
300 { output.state after.block =
301 'skip$
302 { output.state before.all =
303 'skip$
304 { after.sentence 'output.state := }
305 if$
306 }
307 if$
308 }
309
310 FUNCTION {not}
311 { { #0 }
312 { #1 }
313 if$
314 }
315
316 FUNCTION {and}
317 { 'skip$
318 { pop$ #0 }
319 if$
320 }
321
322 FUNCTION {or}
323 { { pop$ #1 }
324 'skip$
325 if$
326 }
327
328 FUNCTION {new.block.checka}
329 { empty$
330 'skip$
331 'new.block
332 if$
333 }
334
335 FUNCTION {new.block.checkb}
336 { empty$
337 swap$ empty$
338 and
339 'skip$
340 'new.block
341 if$
342 }
343
344 FUNCTION {new.sentence.checka}
345 { empty$
346 'skip$
347 'new.sentence
348 if$
349 }
350
351 FUNCTION {new.sentence.checkb}
352 { empty$
353 swap$ empty$
354 and
355 'skip$
356 'new.sentence
357 if$
358 }
359
360 FUNCTION {field.or.null}
361 { duplicate$ empty$
362 { pop$ "" }
363 'skip$
364 if$
365 }
366
367 FUNCTION {emphasize}
368 { duplicate$ empty$
369 { pop$ "" }
370 { "{\em " swap$ * "}" * }
371 if$
372 }
373
374 INTEGERS { nameptr namesleft numnames }
375
376 FUNCTION {format.names}
377 { 's :=
378 #1 'nameptr :=
379 s num.names$ 'numnames :=
380 numnames 'namesleft :=
381 { namesleft #0 > }
382 { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
383 nameptr #1 >
384 { namesleft #1 >
385 { ", " * t * }
386 { numnames #2 >
387 { "," * }
388 'skip$
389 if$
390 t "others" =
391 { " et~al." * }
392 { " and " * t * }
393 if$
394 }
395 if$
396 }
397 't
398 if$
399 nameptr #1 + 'nameptr :=
400 namesleft #1 - 'namesleft :=
401 }
402 while$
403 }
404
405 FUNCTION {format.authors}
406 { author empty$
407 { "" }
408 { author format.names }
409 if$
410 }
411
412 FUNCTION {format.editors}
413 { editor empty$
414 { "" }
415 { editor format.names
416 editor num.names$ #1 >
417 { ", editors" * }
418 { ", editor" * }
419 if$
420 }
421 if$
422 }
423
424 FUNCTION {format.title}
425 { title empty$
426 { "" }
427 { title "t" change.case$ }
428 if$
429 }
430
431 FUNCTION {n.dashify}
432 { 't :=
433 ""
434 { t empty$ not }
435 { t #1 #1 substring$ "-" =
436 { t #1 #2 substring$ "--" = not
437 { "--" *
438 t #2 global.max$ substring$ 't :=
439 }
440 { { t #1 #1 substring$ "-" = }
441 { "-" *
442 t #2 global.max$ substring$ 't :=
443 }
444 while$
445 }
446 if$
447 }
448 { t #1 #1 substring$ *
449 t #2 global.max$ substring$ 't :=
450 }
451 if$
452 }
453 while$
454 }
455
456 FUNCTION {format.date}
457 { year empty$
458 { month empty$
459 { "" }
460 { "there's a month but no year in " cite$ * warning$
461 month
462 }
463 if$
464 }
465 { month empty$
466 'year
467 { month " " * year * }
468 if$
469 }
470 if$
471 }
472
473 FUNCTION {format.btitle}
474 { title emphasize
475 }
476
477 FUNCTION {tie.or.space.connect}
478 { duplicate$ text.length$ #3 <
479 { "~" }
480 { " " }
481 if$
482 swap$ * *
483 }
484
485 FUNCTION {either.or.check}
486 { empty$
487 'pop$
488 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
489 if$
490 }
491
492 FUNCTION {format.bvolume}
493 { volume empty$
494 { "" }
495 { "volume" volume tie.or.space.connect
496 series empty$
497 'skip$
498 { " of " * series emphasize * }
499 if$
500 "volume and number" number either.or.check
501 }
502 if$
503 }
504
505 FUNCTION {format.number.series}
506 { volume empty$
507 { number empty$
508 { series field.or.null }
509 { output.state mid.sentence =
510 { "number" }
511 { "Number" }
512 if$
513 number tie.or.space.connect
514 series empty$
515 { "there's a number but no series in " cite$ * warning$ }
516 { " in " * series * }
517 if$
518 }
519 if$
520 }
521 { "" }
522 if$
523 }
524
525 FUNCTION {format.edition}
526 { edition empty$
527 { "" }
528 { output.state mid.sentence =
529 { edition "l" change.case$ " edition" * }
530 { edition "t" change.case$ " edition" * }
531 if$
532 }
533 if$
534 }
535
536 INTEGERS { multiresult }
537
538 FUNCTION {multi.page.check}
539 { 't :=
540 #0 'multiresult :=
541 { multiresult not
542 t empty$ not
543 and
544 }
545 { t #1 #1 substring$
546 duplicate$ "-" =
547 swap$ duplicate$ "," =
548 swap$ "+" =
549 or or
550 { #1 'multiresult := }
551 { t #2 global.max$ substring$ 't := }
552 if$
553 }
554 while$
555 multiresult
556 }
557
558 FUNCTION {format.pages}
559 { pages empty$
560 { "" }
561 { pages multi.page.check
562 { "pages" pages n.dashify tie.or.space.connect }
563 { "page" pages tie.or.space.connect }
564 if$
565 }
566 if$
567 }
568
569 FUNCTION {format.vol.num.pages}
570 { volume field.or.null
571 number empty$
572 'skip$
573 { "(" number * ")" * *
574 volume empty$
575 { "there's a number but no volume in " cite$ * warning$ }
576 'skip$
577 if$
578 }
579 if$
580 pages empty$
581 'skip$
582 { duplicate$ empty$
583 { pop$ format.pages }
584 { ":" * pages n.dashify * }
585 if$
586 }
587 if$
588 }
589
590 FUNCTION {format.chapter.pages}
591 { chapter empty$
592 'format.pages
593 { type empty$
594 { "chapter" }
595 { type "l" change.case$ }
596 if$
597 chapter tie.or.space.connect
598 pages empty$
599 'skip$
600 { ", " * format.pages * }
601 if$
602 }
603 if$
604 }
605
606 FUNCTION {format.in.ed.booktitle}
607 { booktitle empty$
608 { "" }
609 { editor empty$
610 { "In " booktitle emphasize * }
611 { "In " format.editors * ", " * booktitle emphasize * }
612 if$
613 }
614 if$
615 }
616
617 FUNCTION {empty.misc.check}
618 { author empty$ title empty$ howpublished empty$
619 month empty$ year empty$ note empty$
620 and and and and and
621 key empty$ not and
622 { "all relevant fields are empty in " cite$ * warning$ }
623 'skip$
624 if$
625 }
626
627 FUNCTION {format.thesis.type}
628 { type empty$
629 'skip$
630 { pop$
631 type "t" change.case$
632 }
633 if$
634 }
635
636 FUNCTION {format.tr.number}
637 { type empty$
638 { "Technical Report" }
639 'type
640 if$
641 number empty$
642 { "t" change.case$ }
643 { number tie.or.space.connect }
644 if$
645 }
646
647 FUNCTION {format.article.crossref}
648 { key empty$
649 { journal empty$
650 { "need key or journal for " cite$ * " to crossref " * crossref *
651 warning$
652 ""
653 }
654 { "In {\em " journal * "\/}" * }
655 if$
656 }
657 { "In " key * }
658 if$
659 " \cite{" * crossref * "}" *
660 }
661
662 FUNCTION {format.crossref.editor}
663 { editor #1 "{vv~}{ll}" format.name$
664 editor num.names$ duplicate$
665 #2 >
666 { pop$ " et~al." * }
667 { #2 <
668 'skip$
669 { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
670 { " et~al." * }
671 { " and " * editor #2 "{vv~}{ll}" format.name$ * }
672 if$
673 }
674 if$
675 }
676 if$
677 }
678
679 FUNCTION {format.book.crossref}
680 { volume empty$
681 { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
682 "In "
683 }
684 { "Volume" volume tie.or.space.connect
685 " of " *
686 }
687 if$
688 editor empty$
689 editor field.or.null author field.or.null =
690 or
691 { key empty$
692 { series empty$
693 { "need editor, key, or series for " cite$ * " to crossref " *
694 crossref * warning$
695 "" *
696 }
697 { "{\em " * series * "\/}" * }
698 if$
699 }
700 { key * }
701 if$
702 }
703 { format.crossref.editor * }
704 if$
705 " \cite{" * crossref * "}" *
706 }
707
708 FUNCTION {format.incoll.inproc.crossref}
709 { editor empty$
710 editor field.or.null author field.or.null =
711 or
712 { key empty$
713 { booktitle empty$
714 { "need editor, key, or booktitle for " cite$ * " to crossref " *
715 crossref * warning$
716 ""
717 }
718 { "In {\em " booktitle * "\/}" * }
719 if$
720 }
721 { "In " key * }
722 if$
723 }
724 { "In " format.crossref.editor * }
725 if$
726 " \cite{" * crossref * "}" *
727 }
728
729 % urlbst...
730 % Functions for making hypertext links.
731 % In all cases, the stack has (link-text href-url)
732 %
733 % make 'null' specials
734 FUNCTION {make.href.null}
735 {
736 pop$
737 }
738 % make hypertex specials
739 FUNCTION {make.href.hypertex}
740 {
741 "\special {html:<a href=" quote$ *
742 swap$ * quote$ * "> }" * swap$ *
743 "\special {html:</a>}" *
744 }
745 % make hyperref specials
746 FUNCTION {make.href.hyperref}
747 {
748 "\href {" swap$ * "} {\path{" * swap$ * "}}" *
749 }
750 FUNCTION {make.href}
751 { hrefform #2 =
752 'make.href.hyperref % hrefform = 2
753 { hrefform #1 =
754 'make.href.hypertex % hrefform = 1
755 'make.href.null % hrefform = 0 (or anything else)
756 if$
757 }
758 if$
759 }
760
761 % If inlinelinks is true, then format.url should be a no-op, since it's
762 % (a) redundant, and (b) could end up as a link-within-a-link.
763 FUNCTION {format.url}
764 { inlinelinks #1 = url empty$ or
765 { "" }
766 { hrefform #1 =
767 { % special case -- add HyperTeX specials
768 urlintro "\url{" url * "}" * url make.href.hypertex * }
769 { urlintro "\url{" * url * "}" * }
770 if$
771 }
772 if$
773 }
774 FUNCTION {format.eprint}
775 { eprint empty$
776 { "" }
777 { eprintprefix eprint * eprinturl eprint * make.href }
778 if$
779 }
780
781 FUNCTION {format.doi}
782 { doi empty$
783 { "" }
784 { doi parse.doi % leaves "https://doi.org/DOI" DOI on the stack
785 's := 't :=
786 doiform #1 =
787 { "\doi{" s * "}" * }
788 { doiprefix s * t make.href }
789 if$
790 }
791 if$
792 }
793
794 FUNCTION {format.pubmed}
795 { pubmed empty$
796 { "" }
797 { pubmedprefix pubmed * pubmedurl pubmed * make.href }
798 if$
799 }
800
801 % Output a URL. We can't use the more normal idiom (something like
802 % `format.url output'), because the `inbrackets' within
803 % format.lastchecked applies to everything between calls to `output',
804 % so that `format.url format.lastchecked * output' ends up with both
805 % the URL and the lastchecked in brackets.
806 FUNCTION {output.url}
807 { url empty$
808 'skip$
809 { new.block
810 format.url output
811 format.lastchecked output
812 }
813 if$
814 }
815
816 FUNCTION {output.web.refs}
817 {
818 new.block
819 inlinelinks
820 'skip$ % links were inline -- don't repeat them
821 { % If the generated DOI will be the same as the URL,
822 % then don't print the URL (thanks to Joseph Wright
823 % for (the original version of) this code,
824 % at http://tex.stackexchange.com/questions/5660)
825 adddoi
826 doi empty$ { "X" } { doi parse.doi pop$ } if$ % DOI URL to be generated
827 url empty$ { "Y" } { url } if$ % the URL, or "Y" if empty
828 = % are the strings equal?
829 and
830 'skip$
831 { output.url }
832 if$
833 addeprints eprint empty$ not and
834 { format.eprint output.nonnull }
835 'skip$
836 if$
837 adddoi doi empty$ not and
838 { format.doi output.nonnull }
839 'skip$
840 if$
841 addpubmed pubmed empty$ not and
842 { format.pubmed output.nonnull }
843 'skip$
844 if$
845 }
846 if$
847 }
848
849 % Wrapper for output.bibitem.original.
850 % If the URL field is not empty, set makeinlinelink to be true,
851 % so that an inline link will be started at the next opportunity
852 FUNCTION {output.bibitem}
853 { outside.brackets 'bracket.state :=
854 output.bibitem.original
855 inlinelinks url empty$ not doi empty$ not or pubmed empty$ not or eprint empty$ not or and
856 { #1 'makeinlinelink := }
857 { #0 'makeinlinelink := }
858 if$
859 }
860
861 % Wrapper for fin.entry.original
862 FUNCTION {fin.entry}
863 { output.web.refs % urlbst
864 makeinlinelink % ooops, it appears we didn't have a title for inlinelink
865 { possibly.setup.inlinelink % add some artificial link text here, as a fallback
866 linktextstring output.nonnull }
867 'skip$
868 if$
869 bracket.state close.brackets = % urlbst
870 { "]" * }
871 'skip$
872 if$
873 fin.entry.original
874 }
875
876 % Webpage entry type.
877 % Title and url fields required;
878 % author, note, year, month, and lastchecked fields optional
879 % See references
880 % ISO 690-2 http://www.nlc-bnc.ca/iso/tc46sc9/standard/690-2e.htm
881 % http://www.classroom.net/classroom/CitingNetResources.html
882 % http://neal.ctstateu.edu/history/cite.html
883 % http://www.cas.usf.edu/english/walker/mla.html
884 % for citation formats for web pages.
885 FUNCTION {webpage}
886 { output.bibitem
887 author empty$
888 { editor empty$
889 'skip$ % author and editor both optional
890 { format.editors output.nonnull }
891 if$
892 }
893 { editor empty$
894 { format.authors output.nonnull }
895 { "can't use both author and editor fields in " cite$ * warning$ }
896 if$
897 }
898 if$
899 new.block
900 title empty$ 'skip$ 'possibly.setup.inlinelink if$
901 format.title "title" output.check
902 inbrackets onlinestring output
903 new.block
904 year empty$
905 'skip$
906 { format.date "year" output.check }
907 if$
908 % We don't need to output the URL details ('lastchecked' and 'url'),
909 % because fin.entry does that for us, using output.web.refs. The only
910 % reason we would want to put them here is if we were to decide that
911 % they should go in front of the rather miscellaneous information in 'note'.
912 new.block
913 note output
914 fin.entry
915 }
916 % ...urlbst to here
917
918
919 FUNCTION {article}
920 { output.bibitem
921 format.authors "author" output.check
922 new.block
923 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
924 format.title "title" output.check
925 new.block
926 crossref missing$
927 { journal emphasize "journal" output.check
928 possibly.setup.inlinelink format.vol.num.pages output% urlbst
929 format.date "year" output.check
930 }
931 { format.article.crossref output.nonnull
932 format.pages output
933 }
934 if$
935 new.block
936 note output
937 fin.entry
938 }
939
940 FUNCTION {book}
941 { output.bibitem
942 author empty$
943 { format.editors "author and editor" output.check }
944 { format.authors output.nonnull
945 crossref missing$
946 { "author and editor" editor either.or.check }
947 'skip$
948 if$
949 }
950 if$
951 new.block
952 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
953 format.btitle "title" output.check
954 crossref missing$
955 { format.bvolume output
956 new.block
957 format.number.series output
958 new.sentence
959 publisher "publisher" output.check
960 address output
961 }
962 { new.block
963 format.book.crossref output.nonnull
964 }
965 if$
966 format.edition output
967 format.date "year" output.check
968 new.block
969 note output
970 fin.entry
971 }
972
973 FUNCTION {booklet}
974 { output.bibitem
975 format.authors output
976 new.block
977 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
978 format.title "title" output.check
979 howpublished address new.block.checkb
980 howpublished output
981 address output
982 format.date output
983 new.block
984 note output
985 fin.entry
986 }
987
988 FUNCTION {inbook}
989 { output.bibitem
990 author empty$
991 { format.editors "author and editor" output.check }
992 { format.authors output.nonnull
993 crossref missing$
994 { "author and editor" editor either.or.check }
995 'skip$
996 if$
997 }
998 if$
999 new.block
1000 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1001 format.btitle "title" output.check
1002 crossref missing$
1003 { format.bvolume output
1004 format.chapter.pages "chapter and pages" output.check
1005 new.block
1006 format.number.series output
1007 new.sentence
1008 publisher "publisher" output.check
1009 address output
1010 }
1011 { format.chapter.pages "chapter and pages" output.check
1012 new.block
1013 format.book.crossref output.nonnull
1014 }
1015 if$
1016 format.edition output
1017 format.date "year" output.check
1018 new.block
1019 note output
1020 fin.entry
1021 }
1022
1023 FUNCTION {incollection}
1024 { output.bibitem
1025 format.authors "author" output.check
1026 new.block
1027 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1028 format.title "title" output.check
1029 new.block
1030 crossref missing$
1031 { format.in.ed.booktitle "booktitle" output.check
1032 format.bvolume output
1033 format.number.series output
1034 format.chapter.pages output
1035 new.sentence
1036 publisher "publisher" output.check
1037 address output
1038 format.edition output
1039 format.date "year" output.check
1040 }
1041 { format.incoll.inproc.crossref output.nonnull
1042 format.chapter.pages output
1043 }
1044 if$
1045 new.block
1046 note output
1047 fin.entry
1048 }
1049
1050 FUNCTION {inproceedings}
1051 { output.bibitem
1052 format.authors "author" output.check
1053 new.block
1054 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1055 format.title "title" output.check
1056 new.block
1057 crossref missing$
1058 { format.in.ed.booktitle "booktitle" output.check
1059 format.bvolume output
1060 format.number.series output
1061 format.pages output
1062 address empty$
1063 { organization publisher new.sentence.checkb
1064 organization output
1065 publisher output
1066 format.date "year" output.check
1067 }
1068 { address output.nonnull
1069 format.date "year" output.check
1070 new.sentence
1071 organization output
1072 publisher output
1073 }
1074 if$
1075 }
1076 { format.incoll.inproc.crossref output.nonnull
1077 format.pages output
1078 }
1079 if$
1080 new.block
1081 note output
1082 fin.entry
1083 }
1084
1085 FUNCTION {conference} { inproceedings }
1086
1087 FUNCTION {manual}
1088 { output.bibitem
1089 author empty$
1090 { organization empty$
1091 'skip$
1092 { organization output.nonnull
1093 address output
1094 }
1095 if$
1096 }
1097 { format.authors output.nonnull }
1098 if$
1099 new.block
1100 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1101 format.btitle "title" output.check
1102 author empty$
1103 { organization empty$
1104 { address new.block.checka
1105 address output
1106 }
1107 'skip$
1108 if$
1109 }
1110 { organization address new.block.checkb
1111 organization output
1112 address output
1113 }
1114 if$
1115 format.edition output
1116 format.date output
1117 new.block
1118 note output
1119 fin.entry
1120 }
1121
1122 FUNCTION {mastersthesis}
1123 { output.bibitem
1124 format.authors "author" output.check
1125 new.block
1126 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1127 format.title "title" output.check
1128 new.block
1129 "Master's thesis" format.thesis.type output.nonnull
1130 school "school" output.check
1131 address output
1132 format.date "year" output.check
1133 new.block
1134 note output
1135 fin.entry
1136 }
1137
1138 FUNCTION {misc}
1139 { output.bibitem
1140 format.authors output
1141 title howpublished new.block.checkb
1142 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1143 format.title output
1144 howpublished new.block.checka
1145 howpublished output
1146 format.date output
1147 new.block
1148 note output
1149 fin.entry
1150 empty.misc.check
1151 }
1152
1153 FUNCTION {phdthesis}
1154 { output.bibitem
1155 format.authors "author" output.check
1156 new.block
1157 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1158 format.btitle "title" output.check
1159 new.block
1160 "PhD thesis" format.thesis.type output.nonnull
1161 school "school" output.check
1162 address output
1163 format.date "year" output.check
1164 new.block
1165 note output
1166 fin.entry
1167 }
1168
1169 FUNCTION {proceedings}
1170 { output.bibitem
1171 editor empty$
1172 { organization output }
1173 { format.editors output.nonnull }
1174 if$
1175 new.block
1176 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1177 format.btitle "title" output.check
1178 format.bvolume output
1179 format.number.series output
1180 address empty$
1181 { editor empty$
1182 { publisher new.sentence.checka }
1183 { organization publisher new.sentence.checkb
1184 organization output
1185 }
1186 if$
1187 publisher output
1188 format.date "year" output.check
1189 }
1190 { address output.nonnull
1191 format.date "year" output.check
1192 new.sentence
1193 editor empty$
1194 'skip$
1195 { organization output }
1196 if$
1197 publisher output
1198 }
1199 if$
1200 new.block
1201 note output
1202 fin.entry
1203 }
1204
1205 FUNCTION {techreport}
1206 { output.bibitem
1207 format.authors "author" output.check
1208 new.block
1209 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1210 format.title "title" output.check
1211 new.block
1212 format.tr.number output.nonnull
1213 institution "institution" output.check
1214 address output
1215 format.date "year" output.check
1216 new.block
1217 note output
1218 fin.entry
1219 }
1220
1221 FUNCTION {unpublished}
1222 { output.bibitem
1223 format.authors "author" output.check
1224 new.block
1225 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1226 format.title "title" output.check
1227 new.block
1228 note "note" output.check
1229 format.date output
1230 fin.entry
1231 }
1232
1233 FUNCTION {default.type} { misc }
1234
1235 MACRO {jan} {"January"}
1236
1237 MACRO {feb} {"February"}
1238
1239 MACRO {mar} {"March"}
1240
1241 MACRO {apr} {"April"}
1242
1243 MACRO {may} {"May"}
1244
1245 MACRO {jun} {"June"}
1246
1247 MACRO {jul} {"July"}
1248
1249 MACRO {aug} {"August"}
1250
1251 MACRO {sep} {"September"}
1252
1253 MACRO {oct} {"October"}
1254
1255 MACRO {nov} {"November"}
1256
1257 MACRO {dec} {"December"}
1258
1259 MACRO {acmcs} {"ACM Computing Surveys"}
1260
1261 MACRO {acta} {"Acta Informatica"}
1262
1263 MACRO {cacm} {"Communications of the ACM"}
1264
1265 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
1266
1267 MACRO {ibmsj} {"IBM Systems Journal"}
1268
1269 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
1270
1271 MACRO {ieeetc} {"IEEE Transactions on Computers"}
1272
1273 MACRO {ieeetcad}
1274 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
1275
1276 MACRO {ipl} {"Information Processing Letters"}
1277
1278 MACRO {jacm} {"Journal of the ACM"}
1279
1280 MACRO {jcss} {"Journal of Computer and System Sciences"}
1281
1282 MACRO {scp} {"Science of Computer Programming"}
1283
1284 MACRO {sicomp} {"SIAM Journal on Computing"}
1285
1286 MACRO {tocs} {"ACM Transactions on Computer Systems"}
1287
1288 MACRO {tods} {"ACM Transactions on Database Systems"}
1289
1290 MACRO {tog} {"ACM Transactions on Graphics"}
1291
1292 MACRO {toms} {"ACM Transactions on Mathematical Software"}
1293
1294 MACRO {toois} {"ACM Transactions on Office Information Systems"}
1295
1296 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
1297
1298 MACRO {tcs} {"Theoretical Computer Science"}
1299
1300 READ
1301
1302 FUNCTION {sortify}
1303 { purify$
1304 "l" change.case$
1305 }
1306
1307 INTEGERS { len }
1308
1309 FUNCTION {chop.word}
1310 { 's :=
1311 'len :=
1312 s #1 len substring$ =
1313 { s len #1 + global.max$ substring$ }
1314 's
1315 if$
1316 }
1317
1318 INTEGERS { et.al.char.used }
1319
1320 FUNCTION {initialize.et.al.char.used}
1321 { #0 'et.al.char.used :=
1322 }
1323
1324 EXECUTE {initialize.et.al.char.used}
1325
1326 FUNCTION {format.lab.names}
1327 { 's :=
1328 s num.names$ 'numnames :=
1329 numnames #1 >
1330 { numnames #4 >
1331 { #3 'namesleft := }
1332 { numnames 'namesleft := }
1333 if$
1334 #1 'nameptr :=
1335 ""
1336 { namesleft #0 > }
1337 { nameptr numnames =
1338 { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" =
1339 { "{\etalchar{+}}" *
1340 #1 'et.al.char.used :=
1341 }
1342 { s nameptr "{v{}}{l{}}" format.name$ * }
1343 if$
1344 }
1345 { s nameptr "{v{}}{l{}}" format.name$ * }
1346 if$
1347 nameptr #1 + 'nameptr :=
1348 namesleft #1 - 'namesleft :=
1349 }
1350 while$
1351 numnames #4 >
1352 { "{\etalchar{+}}" *
1353 #1 'et.al.char.used :=
1354 }
1355 'skip$
1356 if$
1357 }
1358 { s #1 "{v{}}{l{}}" format.name$
1359 duplicate$ text.length$ #2 <
1360 { pop$ s #1 "{ll}" format.name$ #3 text.prefix$ }
1361 'skip$
1362 if$
1363 }
1364 if$
1365 }
1366
1367 FUNCTION {author.key.label}
1368 { author empty$
1369 { key empty$
1370 { cite$ #1 #3 substring$ }
1371 { key #3 text.prefix$ }
1372 if$
1373 }
1374 { author format.lab.names }
1375 if$
1376 }
1377
1378 FUNCTION {author.editor.key.label}
1379 { author empty$
1380 { editor empty$
1381 { key empty$
1382 { cite$ #1 #3 substring$ }
1383 { key #3 text.prefix$ }
1384 if$
1385 }
1386 { editor format.lab.names }
1387 if$
1388 }
1389 { author format.lab.names }
1390 if$
1391 }
1392
1393 FUNCTION {author.key.organization.label}
1394 { author empty$
1395 { key empty$
1396 { organization empty$
1397 { cite$ #1 #3 substring$ }
1398 { "The " #4 organization chop.word #3 text.prefix$ }
1399 if$
1400 }
1401 { key #3 text.prefix$ }
1402 if$
1403 }
1404 { author format.lab.names }
1405 if$
1406 }
1407
1408 FUNCTION {editor.key.organization.label}
1409 { editor empty$
1410 { key empty$
1411 { organization empty$
1412 { cite$ #1 #3 substring$ }
1413 { "The " #4 organization chop.word #3 text.prefix$ }
1414 if$
1415 }
1416 { key #3 text.prefix$ }
1417 if$
1418 }
1419 { editor format.lab.names }
1420 if$
1421 }
1422
1423 FUNCTION {calc.label}
1424 { type$ "book" =
1425 type$ "inbook" =
1426 or
1427 'author.editor.key.label
1428 { type$ "proceedings" =
1429 'editor.key.organization.label
1430 { type$ "manual" =
1431 'author.key.organization.label
1432 'author.key.label
1433 if$
1434 }
1435 if$
1436 }
1437 if$
1438 duplicate$
1439 year field.or.null purify$ #-1 #2 substring$
1440 *
1441 'label :=
1442 year field.or.null purify$ #-1 #4 substring$
1443 *
1444 sortify 'sort.label :=
1445 }
1446
1447 FUNCTION {sort.format.names}
1448 { 's :=
1449 #1 'nameptr :=
1450 ""
1451 s num.names$ 'numnames :=
1452 numnames 'namesleft :=
1453 { namesleft #0 > }
1454 { nameptr #1 >
1455 { " " * }
1456 'skip$
1457 if$
1458 s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
1459 nameptr numnames = t "others" = and
1460 { "et al" * }
1461 { t sortify * }
1462 if$
1463 nameptr #1 + 'nameptr :=
1464 namesleft #1 - 'namesleft :=
1465 }
1466 while$
1467 }
1468
1469 FUNCTION {sort.format.title}
1470 { 't :=
1471 "A " #2
1472 "An " #3
1473 "The " #4 t chop.word
1474 chop.word
1475 chop.word
1476 sortify
1477 #1 global.max$ substring$
1478 }
1479
1480 FUNCTION {author.sort}
1481 { author empty$
1482 { key empty$
1483 { "to sort, need author or key in " cite$ * warning$
1484 ""
1485 }
1486 { key sortify }
1487 if$
1488 }
1489 { author sort.format.names }
1490 if$
1491 }
1492
1493 FUNCTION {author.editor.sort}
1494 { author empty$
1495 { editor empty$
1496 { key empty$
1497 { "to sort, need author, editor, or key in " cite$ * warning$
1498 ""
1499 }
1500 { key sortify }
1501 if$
1502 }
1503 { editor sort.format.names }
1504 if$
1505 }
1506 { author sort.format.names }
1507 if$
1508 }
1509
1510 FUNCTION {author.organization.sort}
1511 { author empty$
1512 { organization empty$
1513 { key empty$
1514 { "to sort, need author, organization, or key in " cite$ * warning$
1515 ""
1516 }
1517 { key sortify }
1518 if$
1519 }
1520 { "The " #4 organization chop.word sortify }
1521 if$
1522 }
1523 { author sort.format.names }
1524 if$
1525 }
1526
1527 FUNCTION {editor.organization.sort}
1528 { editor empty$
1529 { organization empty$
1530 { key empty$
1531 { "to sort, need editor, organization, or key in " cite$ * warning$
1532 ""
1533 }
1534 { key sortify }
1535 if$
1536 }
1537 { "The " #4 organization chop.word sortify }
1538 if$
1539 }
1540 { editor sort.format.names }
1541 if$
1542 }
1543
1544 FUNCTION {presort}
1545 { calc.label
1546 sort.label
1547 " "
1548 *
1549 type$ "book" =
1550 type$ "inbook" =
1551 or
1552 'author.editor.sort
1553 { type$ "proceedings" =
1554 'editor.organization.sort
1555 { type$ "manual" =
1556 'author.organization.sort
1557 'author.sort
1558 if$
1559 }
1560 if$
1561 }
1562 if$
1563 *
1564 " "
1565 *
1566 year field.or.null sortify
1567 *
1568 " "
1569 *
1570 title field.or.null
1571 sort.format.title
1572 *
1573 #1 entry.max$ substring$
1574 'sort.key$ :=
1575 }
1576
1577 ITERATE {presort}
1578
1579 SORT
1580
1581 STRINGS { longest.label last.sort.label next.extra }
1582
1583 INTEGERS { longest.label.width last.extra.num }
1584
1585 FUNCTION {initialize.longest.label}
1586 { "" 'longest.label :=
1587 #0 int.to.chr$ 'last.sort.label :=
1588 "" 'next.extra :=
1589 #0 'longest.label.width :=
1590 #0 'last.extra.num :=
1591 }
1592
1593 FUNCTION {forward.pass}
1594 { last.sort.label sort.label =
1595 { last.extra.num #1 + 'last.extra.num :=
1596 last.extra.num int.to.chr$ 'extra.label :=
1597 }
1598 { "a" chr.to.int$ 'last.extra.num :=
1599 "" 'extra.label :=
1600 sort.label 'last.sort.label :=
1601 }
1602 if$
1603 }
1604
1605 FUNCTION {reverse.pass}
1606 { next.extra "b" =
1607 { "a" 'extra.label := }
1608 'skip$
1609 if$
1610 label extra.label * 'label :=
1611 label width$ longest.label.width >
1612 { label 'longest.label :=
1613 label width$ 'longest.label.width :=
1614 }
1615 'skip$
1616 if$
1617 extra.label 'next.extra :=
1618 }
1619
1620 EXECUTE {initialize.longest.label}
1621
1622 ITERATE {forward.pass}
1623
1624 REVERSE {reverse.pass}
1625
1626 FUNCTION {begin.bib}
1627 { et.al.char.used
1628 { "\newcommand{\etalchar}[1]{$^{#1}$}" write$ newline$ }
1629 'skip$
1630 if$
1631 preamble$ empty$
1632 'skip$
1633 { preamble$ write$ newline$ }
1634 if$
1635 "\begin{thebibliography}{" longest.label * "}" * write$ newline$
1636 }
1637
1638 EXECUTE {begin.bib}
1639
1640 EXECUTE {init.urlbst.variables} % urlbst
1641 EXECUTE {init.state.consts}
1642
1643 ITERATE {call.type$}
1644
1645 FUNCTION {end.bib}
1646 { newline$
1647 "\end{thebibliography}" write$ newline$
1648 }
1649
1650 EXECUTE {end.bib}