Debian Codegraph @

texmf-dist/bibtex/bst/tugboat/tugboat.bst

raw
1 %%% $Id: tugboat.bst 689 2025-11-22 23:17:16Z karl $
2 %%% TUGboat changes are public domain.
3 %%%
4 %%% Modified for TUGboat from abbrvurl.bst:
5 %%% New entry types: @ctan (see ctanbib package);
6 %%% @online and @software (aliases for @misc);
7 %%% @webpage (see definition below).
8 %%% For @misc, the editor field is accepted along with author.
9 %%% For @misc, the organization field is output.
10 %%% If the key field is present, it is always used for sorting,
11 %%% for all entry types.
12 %%% New field bookauthor for @incollection and @inproceedings.
13 %%% Abbreviate "page(s)" to "p(p).",
14 %%% "volume" to "vol.",
15 %%% "editor(s)" to "ed(s).",
16 %%% "edition" to "ed.".
17 %%% Output "Ph.D." rather than "PhD".
18 %%% In number field, output "No." and "no.".
19 %%% In month field, output numbers 01..12 as our preferred abbreviations.
20 %%% Omit spaces between author initials, as in "A.B. Smith".
21 %%% Set urlintro="" and onlinestring="" to omit labels from output.
22 %%% Use \url instead of \href, so we don't require hyperref.
23 %%% Always use https://doi.org/ for the doi url; omit "doi:" from output.
24 %%% If doi is present, omit url, since in practice they are usually
25 %%% the same thing. Should also omit if howpublished is the same
26 %%% value, but we currently don't.
27 %%% Truncate long author lists in format.names (max.names, trunc.num);
28 %%% omit "and" from author lists, per Oren P.
29 %%% Use \emph instead of \em so we get automatic italic corrections.
30 %%% New fields for editors:
31 %%% isbnoutput - output value of isbn field, if present,
32 %%% prefixed by "ISBN~" unless the field already contains "ISBN".
33 %%% isbnspace - output a space instead of a tie after "ISBN".
34 %%% journaltie - ~ instead of space after journal name.
35 %%% monthtie - ~ instead of space after month name.
36 %%% newpage - force page break after entry.
37 %%% nojournalcomma - if set, omit comma after journal name.
38 %%% nowarning - if set, omit empty field warnings from output.check.
39 %%% pagesnodashify - if set, don't convert - to -- in pages field.
40 %%% prebibitem - material output before \bibitem, with newline appended
41 %%% (for example, section headings).
42 %%% urlnewline - force line break before url or doi value.
43 %%% --karl, originally created 24jul18.
44 %%%
45 %%% Modification of BibTeX style file /usr/local/texlive/2009/texmf-dist/bibtex/bst/base/abbrv.bst
46 %%% ... by urlbst, version 0.7 (marked with "% urlbst")
47 %%% See <http://purl.org/nxg/dist/urlbst>
48 %%% Added webpage entry type, and url and lastchecked fields.
49 %%% Added eprint support.
50 %%% Added DOI support.
51 %%% Added PUBMED support.
52 %%% Added hyperref support.
53 %%% Original headers follow...
54
55 % [was] BibTeX standard bibliography style `abbrv'
56 % version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09.
57 % Copyright (C) 1985, all rights reserved.
58 % Copying of this file is authorized only if either
59 % (1) you make absolutely no changes to your copy, including name, or
60 % (2) if you do make changes, you name it something other than
61 % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
62 % This restriction helps ensure that all standard styles are identical.
63 % The file btxbst.doc has the documentation for this style.
64
65 ENTRY
66 { address
67 author
68 bookauthor
69 booktitle
70 chapter
71 edition
72 editor
73 howpublished
74 institution
75 journal
76 key
77 month
78 note
79 number
80 organization
81 pages
82 publisher
83 school
84 series
85 title
86 type
87 volume
88 year
89 eprint % urlbst
90 doi % urlbst
91 pubmed % urlbst
92 url % urlbst
93 lastchecked % urlbst
94 date % ctan
95 urldate % ctan
96 version % ctan
97 %
98 isbn % tub
99 isbnoutput % tub
100 isbnspace % tub
101 journaltie % tub
102 monthtie % tub
103 newpage % tub
104 nojournalcomma % tub
105 nowarning % tub
106 pagesnodashify % tub
107 prebibitem % tub
108 urlnewline % tub
109 }
110 {}
111 { label }
112
113 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
114
115 % urlbst...
116 % urlbst constants and state variables
117 STRINGS { urlintro
118 eprinturl eprintprefix doiprefix doiurl pubmedprefix pubmedurl
119 citedstring onlinestring linktextstring
120 openinlinelink closeinlinelink }
121 INTEGERS { hrefform inlinelinks makeinlinelink
122 addeprints adddoiresolver addpubmedresolver }
123 FUNCTION {init.urlbst.variables}
124 {
125 % The following constants may be adjusted by hand, if desired
126
127 % The first set allow you to enable or disable certain functionality.
128 #1 'addeprints := % 0=no eprints; 1=include eprints
129 #1 'adddoiresolver := % 0=no DOI resolver; 1=include it
130 #1 'addpubmedresolver := % 0=no PUBMED resolver; 1=include it
131 #2 'hrefform := % 0=no crossrefs; 1=hypertex xrefs; 2=hyperref refs
132 #0 'inlinelinks := % 0=URLs explicit; 1=URLs attached to titles
133
134 % String constants, which you _might_ want to tweak.
135 "" 'urlintro := % prefix before URL; typically "Available from:" or "URL":
136 "" 'onlinestring := % indication that resource is online; typically "online"
137 "cited " 'citedstring := % indicator of citation date; typically "cited "
138 "[links]" 'linktextstring := % dummy link text; typically "[link]"
139 "https://arxiv.org/abs/" 'eprinturl := % prefix to make URL from eprint ref
140 "arXiv:" 'eprintprefix := % text prefix printed before eprint ref; typically "arXiv:"
141 "https://doi.org/" 'doiurl := % prefix to make URL from DOI
142 "" 'doiprefix := % text prefix printed before DOI ref; typically "doi:"
143 "https://www.ncbi.nlm.nih.gov/pubmed/" 'pubmedurl := % prefix to make URL from PUBMED
144 "PMID:" 'pubmedprefix := % text prefix printed before PUBMED ref; typically "PMID:"
145
146 % The following are internal state variables, not configuration constants,
147 % so they shouldn't be fiddled with.
148 #0 'makeinlinelink := % state variable managed by possibly.setup.inlinelink
149 "" 'openinlinelink := % ditto
150 "" 'closeinlinelink := % ditto
151 }
152 INTEGERS {
153 bracket.state
154 outside.brackets
155 open.brackets
156 within.brackets
157 close.brackets
158 }
159 % ...urlbst to here
160
161 % emacs-page: generic functions.
162 FUNCTION {not}
163 { { #0 }
164 { #1 }
165 if$
166 }
167
168 FUNCTION {and}
169 { 'skip$
170 { pop$ #0 }
171 if$
172 }
173
174 FUNCTION {or}
175 { { pop$ #1 }
176 'skip$
177 if$
178 }
179
180 % For the doi, sometimes people write doi = "10.x/y"
181 % and sometimes they write doi ="https://doi.org/10.x/y".
182 % So we check if the doi string starts with https://doi.org
183 % (aka the doiurl variable), and only add it if needed.
184 %
185 % This code is from https://tex.stackexchange.com/questions/119237
186 % (thank you, mafp). The original urlbst package solved the problem in a
187 % different (simpler) way in its 0.9.1 (January 2023) release.
188 %
189 % The "X Y contains" function checks if string Y is contained in X.
190 % Although we only need to check if Y is at the beginning of X,
191 % it makes no practical difference, so just use it as-is.
192 %
193 % We use this in output.isbn also. Could use it in other places.
194 %
195 INTEGERS { strl }
196 FUNCTION { string.length }
197 {
198 #1 'strl :=
199 {duplicate$ duplicate$ #1 strl substring$ = not}
200 { strl #1 + 'strl :=}
201 while$
202 pop$ strl
203 }
204
205 INTEGERS {find.length search.start search.end done}
206 STRINGS {find.string find.pattern}
207 FUNCTION {contains}
208 {
209 'find.pattern :=
210 'find.string :=
211 find.pattern string.length 'find.length :=
212 #1 'search.start :=
213 find.string string.length find.length - #2 + 'search.end :=
214 #0 'done :=
215 { search.start search.end < }
216 {
217 find.string search.start find.length substring$ find.pattern =
218 {
219 #1 'done :=
220 search.end 'search.start :=%% stop searching
221 }
222 { #1 search.start + 'search.start := }
223 if$
224 }
225 while$
226 done
227 }
228
229 % emacs-page: subroutines, etc.
230 %
231 FUNCTION {init.state.consts}
232 { #0 'outside.brackets := % urlbst...
233 #1 'open.brackets :=
234 #2 'within.brackets :=
235 #3 'close.brackets := % ...urlbst to here
236
237 #0 'before.all :=
238 #1 'mid.sentence :=
239 #2 'after.sentence :=
240 #3 'after.block :=
241 }
242
243 STRINGS { s t last.output.check }
244
245 % urlbst
246 % arg on stack is what needs to be written.
247 %
248 % If journal is "TUGboat" or "\TUB", we want to omit the following
249 % comma, as in "TUGboat 39(1)" instead of the default "TUGboat, 39(1)".
250 % But for all other journals, we want the comma.
251 %
252 % Furthermore, if field journaltie is non-empty, output a tie after the
253 % journal name instad of a space.
254 %
255 FUNCTION {output.nonnull.original}
256 { 's :=
257 output.state mid.sentence =
258 { last.output.check "journal" = not
259 journal missing$
260 or
261 { ", " * } % not a journal, normal comma+space separator
262 { journal "TUGboat" = journal "\TUB" = or
263 nojournalcomma empty$ not or
264 { skip$ } % TUGboat or no comma requested
265 { "," * } % not TUGboat, want comma
266 if$
267 journaltie empty$
268 { " " }
269 { "~" }
270 if$
271 *
272 }
273 if$
274 write$
275 }
276 { output.state after.block =
277 { add.period$ write$
278 newline$
279 "\newblock " write$
280 }
281 { output.state before.all =
282 'write$
283 { add.period$ " " * write$ }
284 if$
285 }
286 if$
287 mid.sentence 'output.state :=
288 }
289 if$
290 s
291 }
292
293 % urlbst...
294 % The following three functions are for handling inlinelink. They wrap
295 % a block of text which is potentially output with write$ by multiple
296 % other functions, so we don't know the content a priori.
297 % They communicate between each other using the variables makeinlinelink
298 % (which is true if a link should be made), and closeinlinelink (which holds
299 % the string which should close any current link. They can be called
300 % at any time, but start.inlinelink will be a no-op unless something has
301 % previously set makeinlinelink true, and the two ...end.inlinelink functions
302 % will only do their stuff if start.inlinelink has previously set
303 % closeinlinelink to be non-empty.
304 % (thanks to 'ijvm' for suggested code here)
305 FUNCTION {uand}
306 { 'skip$ { pop$ #0 } if$ } % 'and' (which isn't defined at this point in the file)
307 FUNCTION {possibly.setup.inlinelink}
308 { makeinlinelink hrefform #0 > uand
309 { doi empty$ adddoiresolver uand
310 { pubmed empty$ addpubmedresolver uand
311 { eprint empty$ addeprints uand
312 { url empty$
313 { "" }
314 { url }
315 if$ }
316 { eprinturl eprint * }
317 if$ }
318 { pubmedurl pubmed * }
319 if$ }
320 { doiurl doi * }
321 if$
322 % an appropriately-formatted URL is now on the stack
323 hrefform #1 = % hypertex
324 { "\special {html:<a href=" quote$ * swap$ * quote$ * "> }{" * 'openinlinelink :=
325 "\special {html:</a>}" 'closeinlinelink := }
326 { "\href {" swap$ * "} {" * 'openinlinelink := % hrefform=#2 -- hyperref
327 % the space between "} {" matters: a URL of just the right length can cause "\% newline em"
328 "}" 'closeinlinelink := }
329 if$
330 #0 'makeinlinelink :=
331 }
332 'skip$
333 if$ % makeinlinelink
334 }
335 FUNCTION {add.inlinelink}
336 { openinlinelink empty$
337 'skip$
338 { openinlinelink swap$ * closeinlinelink *
339 "" 'openinlinelink :=
340 }
341 if$
342 }
343
344 FUNCTION {output.nonnull}
345 { % Save the thing we've been asked to output
346 's :=
347 % If the bracket-state is close.brackets, then add a close-bracket to
348 % what is currently at the top of the stack, and set bracket.state
349 % to outside.brackets
350 bracket.state close.brackets =
351 { "]" *
352 outside.brackets 'bracket.state :=
353 }
354 'skip$
355 if$
356 bracket.state outside.brackets =
357 { % We're outside all brackets -- this is the normal situation.
358 % Write out what's currently at the top of the stack, using the
359 % original output.nonnull function.
360 s
361 add.inlinelink
362 output.nonnull.original % invoke the original output.nonnull
363 }
364 { % Still in brackets. Add open-bracket or (continuation) comma, add the
365 % new text (in s) to the top of the stack, and move to the close-brackets
366 % state, ready for next time (unless inbrackets resets it). If we come
367 % into this branch, then output.state is carefully undisturbed.
368 bracket.state open.brackets =
369 { " [" * }
370 { ", " * } % bracket.state will be within.brackets
371 if$
372 s *
373 close.brackets 'bracket.state :=
374 }
375 if$
376 }
377
378 % Call this function just before adding something which should be presented in
379 % brackets. bracket.state is handled specially within output.nonnull.
380 FUNCTION {inbrackets}
381 { bracket.state close.brackets =
382 { within.brackets 'bracket.state := } % reset the state: not open nor closed
383 { open.brackets 'bracket.state := }
384 if$
385 }
386
387 FUNCTION {format.lastchecked}
388 { lastchecked empty$
389 { "" }
390 { inbrackets citedstring lastchecked * }
391 if$
392 }
393 % ...urlbst to here
394
395 FUNCTION {output}
396 { duplicate$ empty$
397 'pop$
398 'output.nonnull
399 if$
400 }
401
402 % tub: save name of field (what's on stack, e.g., "journal") in
403 % variable last.output.check for use in output.nonnull.original.
404 FUNCTION {output.check}
405 { 't :=
406 duplicate$ empty$
407 { pop$
408 nowarning empty$
409 { "empty " t * " in " * cite$ * warning$ }
410 'skip$
411 if$
412 }
413 { t 'last.output.check :=
414 output.nonnull }
415 if$
416 }
417
418 % tub: if prebibitem is nonempty, output it, plus a newline.
419 FUNCTION {output.bibitem.original} % urlbst (renamed from output.bibitem, so it can be wrapped below)
420 { newline$
421 prebibitem empty$ { skip$ } { prebibitem write$ newline$ } if$
422 "\bibitem{" write$
423 cite$ write$
424 "}" write$
425 newline$
426 ""
427 before.all 'output.state :=
428 }
429
430 % we wrap this function below to handle urls.
431 % The url string to print (of whatever sort) is on the stack to write$.
432 % If the `urlnewline' field is set, write "\newline" first.
433 FUNCTION {fin.entry.original} % urlbst (renamed from fin.entry)
434 { doi empty$ url empty$ and
435 { add.period$ }
436 {
437 urlnewline empty$ not
438 { "\newline " write$ }
439 'skip$
440 if$
441 }
442 if$
443 write$
444 newline$
445 }
446
447 % ctan
448 FUNCTION {add.blank}
449 { " " * before.all 'output.state :=
450 }
451
452 % ctan
453 FUNCTION {add.colon}
454 { empty$
455 'skip$
456 { before.all 'output.state := ":" output add.blank }
457 if$
458 }
459
460 FUNCTION {new.block}
461 { output.state before.all =
462 'skip$
463 { after.block 'output.state := }
464 if$
465 }
466
467 FUNCTION {new.sentence}
468 { output.state after.block =
469 'skip$
470 { output.state before.all =
471 'skip$
472 { after.sentence 'output.state := }
473 if$
474 }
475 if$
476 }
477
478 FUNCTION {new.block.checka}
479 { empty$
480 'skip$
481 'new.block
482 if$
483 }
484
485 FUNCTION {new.block.checkb}
486 { empty$
487 swap$ empty$
488 and
489 'skip$
490 'new.block
491 if$
492 }
493
494 FUNCTION {new.sentence.checka}
495 { empty$
496 'skip$
497 'new.sentence
498 if$
499 }
500
501 FUNCTION {new.sentence.checkb}
502 { empty$
503 swap$ empty$
504 and
505 'skip$
506 'new.sentence
507 if$
508 }
509
510 FUNCTION {field.or.null}
511 { duplicate$ empty$
512 { pop$ "" }
513 'skip$
514 if$
515 }
516
517 % italic correction should not be added before period or comma, so use \emph.
518 FUNCTION {emphasize}
519 { duplicate$ empty$
520 { pop$ "" }
521 { "\emph{" swap$ * "}" * }
522 if$
523 }
524
525 % emacs-page format functions
526 %%% from trunc-auth.bst (slightly edited):
527 %%% There are two constants that allow for the truncation of a list of author
528 %%% (or editor) names -- max.names and trunc.num. And here's how they work:
529 %%% If there are max.names or fewer in the list, there is no truncation; but
530 %%% if there are more than max.names, the list is truncated before the
531 %%% trunc.num name (i.e., trunc.num-1 names will be printed), which is
532 %%% replaced by trunc.string (such as "et~al."), and names later in the
533 %%% list are omitted.
534 %%% There's also a sanity check, making sure that:
535 %%% 2 <= trunc.num <= max.names + 1
536
537 INTEGERS { max.names trunc.num }
538
539 STRINGS { trunc.string sort.trunc.string } % the two truncation-string versions
540
541 FUNCTION {init.and.check.trunc.consts} % from trunc-auth.bst,
542 { #3 'max.names := % the two relevant integer constants
543 #3 'trunc.num :=
544 "et~al." 'trunc.string := % and string constants for printing
545 "et al" 'sort.trunc.string := % and sorting
546 trunc.num #2 <
547 { "trunc.num=" trunc.num int.to.str$ * " but should be at least 2" *
548 warning$
549 }
550 'skip$
551 if$
552 trunc.num max.names #1 + >
553 { "trunc.num=" trunc.num int.to.str$ *
554 " should be at most max.names + 1 = " * max.names #1 + int.to.str$ *
555 warning$
556 }
557 'skip$
558 if$
559 }
560
561 INTEGERS { nameptr numnames }
562
563 INTEGERS { finalnamenum } % from trunc-auth.bst
564
565 FUNCTION {format.names} % from trunc-auth.bst
566 { 's :=
567 #0 'nameptr :=
568 s num.names$ 'numnames :=
569 numnames max.names > % from trunc-auth.bst
570 { trunc.num 'finalnamenum := } % truncate in this case
571 { numnames 'finalnamenum := }
572 if$
573 { nameptr finalnamenum < }
574 { nameptr #1 + 'nameptr :=
575 % original line:
576 %s nameptr "{f{.}.~}{vv~}{ll}{, jj}" format.name$ 't :=
577 %
578 % But we want to avoid the space that BibTeX usually inserts
579 % between the abbreviations of the tokens, so we get "A.B."
580 % instead of "A. B.".
581 %
582 % So, the "f{.}.~~" here says that, for the first name part (say
583 % "Alex B.") output the abbreviation for the first token ("A"), a
584 % period ("."), the abbreviation for the second token ("B"), and
585 % another period ("."), omitting the normal intertoken space,
586 % as discussed at the very end of btxhak.
587 %
588 % The final ~~ forces a tilde in the output, since we never want a
589 % line break between the initials and the last name.
590 %
591 s nameptr "{f{.}.~~}{vv~}{ll}{, jj}" format.name$ 't :=
592 %
593 nameptr #1 =
594 't
595 { ", " * % comma but no "and" before final name
596 nameptr finalnamenum <
597 { t * }
598 { numnames max.names >
599 { trunc.string * }
600 { t "others" =
601 { "et~al." * }
602 { t * }
603 if$
604 }
605 if$
606 }
607 if$
608 }
609 if$
610 }
611 while$
612 }
613
614 FUNCTION {format.authors}
615 { author empty$
616 { "" }
617 { author format.names }
618 if$
619 }
620
621 FUNCTION {format.editors}
622 { editor empty$
623 { "" }
624 { editor format.names
625 editor num.names$ #1 >
626 { ", eds." * }
627 { ", ed." * }
628 if$
629 }
630 if$
631 }
632
633 % if editor is non-empty, format it.
634 % else if bookauthor is non-empty, format it.
635 % else nothing.
636 FUNCTION {format.editors.bookauthors}
637 { editor empty$
638 { bookauthor empty$
639 { "" }
640 { bookauthor format.names }
641 if$
642 }
643 { format.editors }
644 if$
645 }
646
647 FUNCTION {format.title}
648 { title empty$
649 { "" }
650 { title "t" change.case$ }
651 if$
652 }
653
654 % Return argument with - replaced by -- (unless already --),
655 % unless pagesnodashify is set, in which case do nothing.
656 %
657 % We use pagesnodashify when an article has a reference to another article
658 % in the same issue, in which case we use (from tb137kopp-microtemplates):
659 % pages = "{\thisissuepageref{beeton-basic}}",
660 % and that - clearly should not become --. Although we can work around
661 % it by using a macro instead of a literal -, that's ugly.
662 %
663 FUNCTION {n.dashify}
664 { 't :=
665 pagesnodashify empty$
666 {
667 ""
668 { t empty$ not }
669 { t #1 #1 substring$ "-" =
670 { t #1 #2 substring$ "--" = not
671 { "--" *
672 t #2 global.max$ substring$ 't :=
673 }
674 { { t #1 #1 substring$ "-" = }
675 { "-" *
676 t #2 global.max$ substring$ 't :=
677 }
678 while$
679 }
680 if$
681 }
682 { t #1 #1 substring$ *
683 t #2 global.max$ substring$ 't :=
684 }
685 if$
686 }
687 while$
688 }
689 {
690 t
691 }
692 if$
693 }
694
695 % tub: assume month is nonempty. If numeric (biblatex), output
696 % our preferred month abbreviation; else output as-is.
697 % There is no way to reuse the macro definitions previously made here,
698 % so just write them out again.
699 FUNCTION {format.month}
700 { month "01" = month "1" = or
701 { "Jan." }
702 { month "02" = month "2" = or
703 { "Feb." }
704 { month "03" = month "3" = or
705 { "Mar." }
706 { month "03" = month "4" = or
707 { "Apr." }
708 { month "05" = month "5" = or
709 { "May" }
710 { month "06" = month "6" = or
711 { "June" }
712 { month "07" = month "7" = or
713 { "July" }
714 { month "08" = month "8" = or
715 { "Aug." }
716 { month "09" = month "9" = or
717 { "Sept." }
718 { month "10" =
719 { "Oct." }
720 { month "11" =
721 { "Nov." }
722 { month "12" =
723 { "Dec." }
724 { month }
725 if$
726 }
727 if$
728 }
729 if$
730 }
731 if$
732 }
733 if$
734 }
735 if$
736 }
737 if$
738 }
739 if$
740 }
741 if$
742 }
743 if$
744 }
745 if$
746 }
747 if$
748 }
749
750 FUNCTION {format.date}
751 { year empty$
752 { month empty$
753 { "" }
754 { "there's a month but no year in " cite$ * warning$
755 month
756 }
757 if$
758 }
759 { month empty$
760 'year
761 { format.month
762 % tie months by default, since we use abbrevs.
763 % If monthtie is set to 0, do not tie.
764 monthtie empty$
765 { "~" }
766 {
767 monthtie "0" =
768 { " " }
769 { "~" }
770 if$
771 }
772 if$
773 *
774 year *
775 }
776 if$
777 }
778 if$
779 }
780
781 % output the date field, instead of using month/year.
782 FUNCTION {format.date.direct}
783 { date empty$
784 {""}
785 { date }
786 if$
787 }
788
789 FUNCTION {format.btitle}
790 { title emphasize
791 }
792
793 FUNCTION {tie.or.space.connect}
794 { duplicate$ text.length$ #3 <
795 { "~" }
796 { " " }
797 if$
798 swap$ * *
799 }
800
801 FUNCTION {either.or.check}
802 { empty$
803 'pop$
804 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
805 if$
806 }
807
808 FUNCTION {format.bvolume}
809 { volume empty$
810 { "" }
811 { "vol." volume tie.or.space.connect
812 series empty$
813 'skip$
814 { " of " * series emphasize * }
815 if$
816 "volume and number" number either.or.check
817 }
818 if$
819 }
820
821 FUNCTION {format.number.series}
822 { volume empty$
823 { number empty$
824 { series field.or.null }
825 { output.state mid.sentence =
826 { "no." }
827 { "No." }
828 if$
829 number tie.or.space.connect
830 series empty$
831 { "there's a number but no series in " cite$ * warning$ }
832 { " in " * series * }
833 if$
834 }
835 if$
836 }
837 { "" }
838 if$
839 }
840
841 FUNCTION {format.edition}
842 { edition empty$
843 { "" }
844 { output.state mid.sentence =
845 { edition "l" change.case$ "~ed." * }
846 { edition "t" change.case$ "~ed." * }
847 if$
848 }
849 if$
850 }
851
852 INTEGERS { multiresult }
853
854 FUNCTION {multi.page.check}
855 { 't :=
856 #0 'multiresult :=
857 { multiresult not
858 t empty$ not
859 and
860 }
861 { t #1 #1 substring$
862 duplicate$ "-" =
863 swap$ duplicate$ "," =
864 swap$ "+" =
865 or or
866 { #1 'multiresult := }
867 { t #2 global.max$ substring$ 't := }
868 if$
869 }
870 while$
871 multiresult
872 }
873
874 FUNCTION {format.pages}
875 { pages empty$
876 { "" }
877 { pages multi.page.check
878 { "pp.~" pages n.dashify * }
879 { "p.~" pages * }
880 if$
881 }
882 if$
883 }
884
885 FUNCTION {format.vol.num.pages}
886 { volume field.or.null
887 number empty$
888 'skip$
889 { "(" number * ")" * *
890 volume empty$
891 { nowarning empty$
892 { "there's a number but no volume in " cite$ * warning$ }
893 'skip$
894 if$
895 }
896 'skip$
897 if$
898 }
899 if$
900 pages empty$
901 'skip$
902 { duplicate$ empty$
903 { pop$ format.pages }
904 { ":" * pages n.dashify * }
905 if$
906 }
907 if$
908 }
909
910 FUNCTION {format.chapter.pages}
911 { chapter empty$
912 'format.pages
913 { type empty$
914 { "ch." }
915 { type "l" change.case$ }
916 if$
917 chapter tie.or.space.connect
918 pages empty$
919 'skip$
920 { ", " * format.pages * }
921 if$
922 }
923 if$
924 }
925
926 % handle possible bookauthor.
927 % original line: { "In " format.editors * ", " * booktitle emphasize * }
928
929 FUNCTION {format.in.ed.booktitle}
930 { booktitle empty$
931 { "" }
932 { editor empty$
933 bookauthor empty$
934 and
935 { "In~" booktitle emphasize * }
936 { "In~" booktitle emphasize * ", " format.editors.bookauthors * * }
937 if$
938 }
939 if$
940 }
941
942 FUNCTION {empty.misc.check}
943 { author empty$ title empty$ howpublished empty$
944 month empty$ year empty$ note empty$
945 and and and and and
946 key empty$ not and
947 { "all relevant fields are empty in " cite$ * warning$ }
948 'skip$
949 if$
950 }
951
952 FUNCTION {format.thesis.type}
953 { type empty$
954 'skip$
955 { pop$
956 type "t" change.case$
957 }
958 if$
959 }
960
961 FUNCTION {format.tr.number}
962 { type empty$
963 { "Technical Report" }
964 'type
965 if$
966 number empty$
967 { "t" change.case$ }
968 { number tie.or.space.connect }
969 if$
970 }
971
972 FUNCTION {format.article.crossref}
973 { key empty$
974 { journal empty$
975 { "need key or journal for " cite$ * " to crossref " * crossref *
976 warning$
977 ""
978 }
979 { "In \emph{" journal * "}" * }
980 if$
981 }
982 { "In~" key * }
983 if$
984 " \cite{" * crossref * "}" *
985 }
986
987 FUNCTION {format.crossref.editor}
988 { editor #1 "{vv~}{ll}" format.name$
989 editor num.names$ duplicate$
990 #2 >
991 { pop$ " et~al." * }
992 { #2 <
993 'skip$
994 { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
995 { " et~al." * }
996 { " and " * editor #2 "{vv~}{ll}" format.name$ * }
997 if$
998 }
999 if$
1000 }
1001 if$
1002 }
1003
1004 FUNCTION {format.book.crossref}
1005 { volume empty$
1006 { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
1007 "In~"
1008 }
1009 { "Volume" volume tie.or.space.connect
1010 " of " *
1011 }
1012 if$
1013 editor empty$
1014 editor field.or.null author field.or.null =
1015 or
1016 { key empty$
1017 { series empty$
1018 { "need editor, key, or series for " cite$ * " to crossref " *
1019 crossref * warning$
1020 "" *
1021 }
1022 { "\emph{" * series * "}" * }
1023 if$
1024 }
1025 { key * }
1026 if$
1027 }
1028 { format.crossref.editor * }
1029 if$
1030 " \cite{" * crossref * "}" *
1031 }
1032
1033 FUNCTION {format.incoll.inproc.crossref}
1034 { editor empty$
1035 editor field.or.null author field.or.null =
1036 or
1037 { key empty$
1038 { booktitle empty$
1039 { "need editor, key, or booktitle for " cite$ * " to crossref " *
1040 crossref * warning$
1041 ""
1042 }
1043 { "In \emph{" booktitle * "}" * }
1044 if$
1045 }
1046 { "In~" key * }
1047 if$
1048 }
1049 { "In~" format.crossref.editor * }
1050 if$
1051 " \cite{" * crossref * "}" *
1052 }
1053
1054 % Output ISBN only if explicitly requested; usually there is a url, or
1055 % the other information seems sufficient. But sometimes for books in
1056 % multiple editions, etc., it's useful.
1057 %
1058 % If the value contains the string "ISBN", just output it; otherwise,
1059 % first output the string "ISBN". And, if we do output it, separate that
1060 % "ISBN" string from the value with a tie by default, or with a space if
1061 % the field isbnspace is set. Ordinarily we wouldn't want a line break
1062 % there, but occasionally it might be less bad than alternatives.
1063 %
1064 FUNCTION {output.isbn}
1065 {
1066 isbn empty$ not isbnoutput empty$ not and
1067 { isbn "ISBN" contains
1068 { "" } % their value already has "ISBN", no extra output.
1069 { "ISBN"
1070 isbnspace empty$ { "~" } { " " } if$
1071 *
1072 }
1073 if$
1074 isbn *
1075 "isbn" output.check }
1076 'skip$ % isbn was empty, or isbnoutput not specified
1077 if$
1078 new.block
1079 }
1080
1081 % emacs-page urlbst...
1082 % Functions for making hypertext links.
1083 % In all cases, the stack has (link-text href-url)
1084 %
1085 % make 'null' specials
1086 FUNCTION {make.href.null}
1087 {
1088 pop$
1089 }
1090 % make hypertex specials
1091 FUNCTION {make.href.hypertex}
1092 {
1093 "\special {html:<a href=" quote$ *
1094 swap$ * quote$ * "> }" * swap$ *
1095 "\special {html:</a>}" *
1096 }
1097 % make hyperref specials. Use \url rather than \href so that we don't
1098 % require loading hyperref (ltugboat provides \url in all cases),
1099 % thus we ignore one of the arguments.
1100 FUNCTION {make.href.hyperref}
1101 {
1102 "\url{" swap$ * "}" * swap$ pop$
1103 }
1104 FUNCTION {make.href}
1105 { hrefform #2 =
1106 'make.href.hyperref % hrefform = 2
1107 { hrefform #1 =
1108 'make.href.hypertex % hrefform = 1
1109 'make.href.null % hrefform = 0 (or anything else)
1110 if$
1111 }
1112 if$
1113 }
1114
1115 % This function, format.url, should do nothing if
1116 % - inlinelinks is true, since then it's (a) redundant, and (b) could
1117 % end up as a link-within-a-link.
1118 % - if the url is empty.
1119 % - if the doi field is present, on the assumption that it most
1120 % likely redundantly specifies the same info; this seems to be what
1121 % people do in practice, unfortunately.
1122 %
1123 % If we find this case again in the future, we'll implement it.
1124 % For tb141lang-dh, howpublished is intentionally and reasonably
1125 % separate from url.
1126 % - if the howpublished field contains the same value as the url field;
1127 FUNCTION {format.url}
1128 { inlinelinks #1 = url empty$ or
1129 doi empty$ not or
1130 { "" }
1131 { hrefform #1 =
1132 { % #1 means add HyperTeX, which we never do
1133 urlintro "\url{" url * "}" * url make.href.hypertex * }
1134 { urlintro "\url{" * url * "}" * }
1135 if$
1136 }
1137 if$
1138 }
1139
1140 FUNCTION {format.urldate}
1141 { urldate empty$
1142 {""}
1143 % {'skip$}
1144 {"last visited: " urldate *}
1145 if$
1146 }
1147
1148 FUNCTION {format.version}
1149 { version empty$
1150 {""}
1151 {"version " version * }
1152 if$
1153 }
1154
1155 FUNCTION {format.eprint}
1156 { eprint empty$
1157 { "" }
1158 { eprintprefix eprint * eprinturl eprint * make.href }
1159 if$
1160 }
1161
1162 FUNCTION {format.pubmed}
1163 { pubmed empty$
1164 { "" }
1165 { pubmedprefix pubmed * pubmedurl pubmed * make.href }
1166 if$
1167 }
1168
1169 % The original definition, left here for comparison.
1170 %FUNCTION {format.doi.orig}
1171 %{ doi empty$
1172 % { "" }
1173 % { doiprefix doi * doiurl doi * make.href }
1174 % if$
1175 %}
1176
1177 FUNCTION {format.doi}
1178 { doi empty$
1179 { "" }
1180 { doiprefix doi *
1181 doi doiurl contains
1182 { "" }
1183 { doiurl }
1184 if$
1185 doi *
1186 make.href
1187 }
1188 if$
1189 }
1190
1191 % Output a URL. We can't use the more normal idiom (something like
1192 % `format.url output'), because the `inbrackets' within
1193 % format.lastchecked applies to everything between calls to `output',
1194 % so that `format.url format.lastchecked * output' ends up with both
1195 % the URL and the lastchecked in brackets.
1196 %
1197 FUNCTION {output.url}
1198 { url empty$
1199 'skip$
1200 { new.block
1201 format.url output
1202 format.lastchecked output
1203 }
1204 if$
1205 }
1206
1207 FUNCTION {output.web.refs}
1208 {
1209 new.block
1210 inlinelinks
1211 'skip$ % links were inline -- don't repeat them
1212 {
1213 output.url
1214 addeprints eprint empty$ not and
1215 { format.eprint output.nonnull }
1216 'skip$
1217 if$
1218 adddoiresolver doi empty$ not and
1219 { format.doi output.nonnull }
1220 'skip$
1221 if$
1222 addpubmedresolver pubmed empty$ not and
1223 { format.pubmed output.nonnull }
1224 'skip$
1225 if$
1226 }
1227 if$
1228 }
1229
1230 % Wrapper for output.bibitem.original.
1231 % If the URL field is not empty, set makeinlinelink to be true,
1232 % so that an inline link will be started at the next opportunity
1233 FUNCTION {output.bibitem}
1234 { outside.brackets 'bracket.state :=
1235 output.bibitem.original
1236 inlinelinks url empty$ not doi empty$ not or pubmed empty$ not or eprint empty$ not or and
1237 { #1 'makeinlinelink := }
1238 { #0 'makeinlinelink := }
1239 if$
1240 }
1241
1242 % Wrapper for fin.entry.original
1243 FUNCTION {fin.entry}
1244 { output.web.refs % urlbst
1245 makeinlinelink % oops, it appears we didn't have a title for inlinelink
1246 { possibly.setup.inlinelink % add some artificial link text here, as a fallback
1247 linktextstring output.nonnull }
1248 'skip$
1249 if$
1250 bracket.state close.brackets = % urlbst
1251 { "]" * }
1252 'skip$
1253 if$
1254 fin.entry.original
1255 newpage empty$ not
1256 { "\newpage " write$ }
1257 'skip$
1258 if$
1259 }
1260
1261 % emacs-page
1262 % Webpage entry type.
1263 % Title and url fields required;
1264 % author, note, year, month, and lastchecked fields optional
1265 % See references
1266 % [gone] ISO 690-2 http://www.nlc-bnc.ca/iso/tc46sc9/standard/690-2e.htm
1267 % [gone] http://www.classroom.net/classroom/CitingNetResources.html
1268 % [gone] http://neal.ctstateu.edu/history/cite.html
1269 % [gone] http://www.cas.usf.edu/english/walker/mla.html
1270 % for citation formats for web pages.
1271 FUNCTION {webpage}
1272 { output.bibitem
1273 author empty$
1274 { editor empty$
1275 'skip$ % author and editor both optional
1276 { format.editors output.nonnull }
1277 if$
1278 }
1279 { editor empty$
1280 { format.authors output.nonnull }
1281 { "can't use both author and editor fields in " cite$ * warning$ }
1282 if$
1283 }
1284 if$
1285 new.block
1286 title empty$ 'skip$ 'possibly.setup.inlinelink if$
1287 format.title "title" output.check
1288 % This causes the year to be output in brackets, which we don't want:
1289 % inbrackets onlinestring output
1290 new.block
1291 year empty$
1292 'skip$
1293 { format.date "year" output.check }
1294 if$
1295 % We don't need to output the URL details ('lastchecked' and 'url'),
1296 % because fin.entry does that for us, using output.web.refs. The only
1297 % reason we would want to put them here is if we were to decide that
1298 % they should go in front of the rather miscellaneous information in 'note'.
1299 new.block
1300 note output
1301 fin.entry
1302 }
1303 % ...urlbst to here
1304
1305 FUNCTION {article}
1306 { output.bibitem
1307 format.authors "author" output.check
1308 new.block
1309 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1310 format.title "title" output.check
1311 new.block
1312 crossref missing$
1313 { journal emphasize "journal" output.check
1314 possibly.setup.inlinelink format.vol.num.pages output% urlbst
1315 format.date "year" output.check
1316 }
1317 { format.article.crossref output.nonnull
1318 format.pages output
1319 }
1320 if$
1321 new.block
1322 note output
1323 fin.entry
1324 }
1325
1326 FUNCTION {book}
1327 { output.bibitem
1328 author empty$
1329 { format.editors "author and editor" output.check }
1330 { format.authors output.nonnull
1331 crossref missing$
1332 { "author and editor" editor either.or.check }
1333 'skip$
1334 if$
1335 }
1336 if$
1337 new.block
1338 %
1339 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1340 format.btitle "title" output.check
1341 crossref missing$
1342 { format.bvolume output
1343 new.block
1344 format.number.series output
1345 new.sentence
1346 publisher "publisher" output.check
1347 address output
1348 }
1349 { new.block
1350 format.book.crossref output.nonnull
1351 }
1352 if$
1353 format.edition output
1354 format.date "year" output.check
1355 new.block
1356 output.isbn
1357 note output
1358 fin.entry
1359 }
1360
1361 FUNCTION {booklet}
1362 { output.bibitem
1363 format.authors output
1364 new.block
1365 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1366 format.title "title" output.check
1367 howpublished address new.block.checkb
1368 howpublished output
1369 address output
1370 format.date output
1371 new.block
1372 note output
1373 fin.entry
1374 }
1375
1376 FUNCTION {inbook}
1377 { output.bibitem
1378 author empty$
1379 { format.editors "author and editor" output.check }
1380 { format.authors output.nonnull
1381 crossref missing$
1382 { "author and editor" editor either.or.check }
1383 'skip$
1384 if$
1385 }
1386 if$
1387 new.block
1388 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1389 format.btitle "title" output.check
1390 crossref missing$
1391 { format.bvolume output
1392 format.chapter.pages "chapter and pages" output.check
1393 new.block
1394 format.number.series output
1395 new.sentence
1396 publisher "publisher" output.check
1397 address output
1398 }
1399 { format.chapter.pages "chapter and pages" output.check
1400 new.block
1401 format.book.crossref output.nonnull
1402 }
1403 if$
1404 format.edition output
1405 format.date "year" output.check
1406 new.block
1407 output.isbn
1408 note output
1409 fin.entry
1410 }
1411
1412 FUNCTION {incollection}
1413 { output.bibitem
1414 format.authors "author" output.check
1415 new.block
1416 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1417 format.title "title" output.check
1418 new.block
1419 crossref missing$
1420 { format.in.ed.booktitle "booktitle" output.check
1421 format.bvolume output
1422 format.number.series output
1423 format.chapter.pages output
1424 new.sentence
1425 publisher "publisher" output.check
1426 address output
1427 format.edition output
1428 format.date "year" output.check
1429 }
1430 { format.incoll.inproc.crossref output.nonnull
1431 format.chapter.pages output
1432 }
1433 if$
1434 new.block
1435 output.isbn
1436 note output
1437 fin.entry
1438 }
1439
1440 FUNCTION {inproceedings}
1441 { output.bibitem
1442 format.authors "author" output.check
1443 new.block
1444 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1445 format.title "title" output.check
1446 new.block
1447 crossref missing$
1448 { format.in.ed.booktitle "booktitle" output.check
1449 format.bvolume output
1450 format.number.series output
1451 format.pages output
1452 address empty$
1453 { organization publisher new.sentence.checkb
1454 organization output
1455 publisher output
1456 format.date "year" output.check
1457 }
1458 { address output.nonnull
1459 format.date "year" output.check
1460 new.sentence
1461 organization output
1462 publisher output
1463 }
1464 if$
1465 }
1466 { format.incoll.inproc.crossref output.nonnull
1467 format.pages output
1468 }
1469 if$
1470 new.block
1471 output.isbn
1472 note output
1473 fin.entry
1474 }
1475
1476 FUNCTION {conference} { inproceedings }
1477
1478 FUNCTION {manual}
1479 { output.bibitem
1480 author empty$
1481 { organization empty$
1482 'skip$
1483 { organization output.nonnull
1484 address output
1485 }
1486 if$
1487 }
1488 { format.authors output.nonnull }
1489 if$
1490 new.block
1491 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1492 format.btitle "title" output.check
1493 author empty$
1494 { organization empty$
1495 { address new.block.checka
1496 address output
1497 }
1498 'skip$
1499 if$
1500 }
1501 { organization address new.block.checkb
1502 organization output
1503 address output
1504 }
1505 if$
1506 format.edition output
1507 format.date output
1508 new.block
1509 output.isbn
1510 note output
1511 fin.entry
1512 }
1513
1514 FUNCTION {mastersthesis}
1515 { output.bibitem
1516 format.authors "author" output.check
1517 new.block
1518 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1519 format.title "title" output.check
1520 new.block
1521 "Master's thesis" format.thesis.type output.nonnull
1522 school "school" output.check
1523 address output
1524 format.date "year" output.check
1525 new.block
1526 note output
1527 fin.entry
1528 }
1529
1530 FUNCTION {misc}
1531 { output.bibitem
1532 % originally just:
1533 % format.authors output
1534 author empty$
1535 {
1536 editor empty$
1537 'skip$
1538 { format.editors output.nonnull }
1539 if$
1540 }
1541 { format.authors output.nonnull }
1542 if$
1543 %
1544 title howpublished new.block.checkb
1545 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1546 format.title output
1547 howpublished new.block.checka
1548 howpublished output
1549 format.date output
1550 new.block
1551 organization output
1552 note output
1553 fin.entry
1554 empty.misc.check
1555 }
1556
1557 FUNCTION {online}
1558 { misc }
1559
1560 FUNCTION {software}
1561 { misc }
1562
1563 FUNCTION {phdthesis}
1564 { output.bibitem
1565 format.authors "author" output.check
1566 new.block
1567 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1568 format.btitle "title" output.check
1569 new.block
1570 "Ph.D. thesis" format.thesis.type output.nonnull
1571 school "school" output.check
1572 address output
1573 format.date "year" output.check
1574 new.block
1575 note output
1576 fin.entry
1577 }
1578
1579 FUNCTION {proceedings}
1580 { output.bibitem
1581 editor empty$
1582 { organization output }
1583 { format.editors output.nonnull }
1584 if$
1585 new.block
1586 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1587 format.btitle "title" output.check
1588 format.bvolume output
1589 format.number.series output
1590 address empty$
1591 { editor empty$
1592 { publisher new.sentence.checka }
1593 { organization publisher new.sentence.checkb
1594 organization output
1595 }
1596 if$
1597 publisher output
1598 format.date "year" output.check
1599 }
1600 { address output.nonnull
1601 format.date "year" output.check
1602 new.sentence
1603 editor empty$
1604 'skip$
1605 { organization output }
1606 if$
1607 publisher output
1608 }
1609 if$
1610 new.block
1611 output.isbn
1612 note output
1613 fin.entry
1614 }
1615
1616 FUNCTION {techreport}
1617 { output.bibitem
1618 format.authors "author" output.check
1619 new.block
1620 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1621 format.title "title" output.check
1622 new.block
1623 format.tr.number output.nonnull
1624 institution "institution" output.check
1625 address output
1626 format.date "year" output.check
1627 new.block
1628 note output
1629 fin.entry
1630 }
1631
1632 FUNCTION {unpublished}
1633 { output.bibitem
1634 format.authors "author" output.check
1635 new.block
1636 title empty$ 'skip$ 'possibly.setup.inlinelink if$ % urlbst
1637 format.title "title" output.check
1638 new.block
1639 note "note" output.check
1640 format.date output
1641 fin.entry
1642 }
1643
1644 % original for ctan entry:
1645 %{ output.bibitem
1646 % format.authors output
1647 % author add.colon
1648 % format.title output
1649 % format.version output
1650 % note output
1651 % format.longdate output
1652 % format.url output
1653 % format.urldate output
1654 % fin.entry.original
1655 %}
1656
1657 % don't like printing urldates; and url is better last. Break up entry.
1658 FUNCTION {ctan}
1659 { output.bibitem
1660 format.authors "author" output.check
1661 new.block
1662 format.title "title" output.check
1663 format.version output
1664 format.date.direct output
1665 new.block
1666 note output
1667 fin.entry
1668 }
1669
1670 FUNCTION {default.type} { misc }
1671
1672 MACRO {jan} {"Jan."}
1673
1674 MACRO {feb} {"Feb."}
1675
1676 MACRO {mar} {"Mar."}
1677
1678 MACRO {apr} {"Apr."}
1679
1680 MACRO {may} {"May"}
1681
1682 MACRO {jun} {"June"}
1683
1684 MACRO {jul} {"July"}
1685
1686 MACRO {aug} {"Aug."}
1687
1688 MACRO {sep} {"Sept."}
1689
1690 MACRO {oct} {"Oct."}
1691
1692 MACRO {nov} {"Nov."}
1693
1694 MACRO {dec} {"Dec."}
1695
1696 MACRO {acmcs} {"ACM Comput. Surv."}
1697
1698 MACRO {acta} {"Acta Inf."}
1699
1700 MACRO {cacm} {"Commun. ACM"}
1701
1702 MACRO {ibmjrd} {"IBM J. Res. Dev."}
1703
1704 MACRO {ibmsj} {"IBM Syst.~J."}
1705
1706 MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
1707
1708 MACRO {ieeetc} {"IEEE Trans. Comput."}
1709
1710 MACRO {ieeetcad}
1711 {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
1712
1713 MACRO {ipl} {"Inf. Process. Lett."}
1714
1715 MACRO {jacm} {"J.~ACM"}
1716
1717 MACRO {jcss} {"J.~Comput. Syst. Sci."}
1718
1719 MACRO {scp} {"Sci. Comput. Programming"}
1720
1721 MACRO {sicomp} {"SIAM J. Comput."}
1722
1723 MACRO {tocs} {"ACM Trans. Comput. Syst."}
1724
1725 MACRO {tods} {"ACM Trans. Database Syst."}
1726
1727 MACRO {tog} {"ACM Trans. Gr."}
1728
1729 MACRO {toms} {"ACM Trans. Math. Softw."}
1730
1731 MACRO {toois} {"ACM Trans. Office Inf. Syst."}
1732
1733 MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
1734
1735 MACRO {tcs} {"Theoretical Comput. Sci."}
1736
1737 READ
1738
1739 EXECUTE {init.and.check.trunc.consts} % from trunc-auth.bst
1740
1741 % emacs-page
1742
1743 FUNCTION {sortify}
1744 { purify$
1745 "l" change.case$
1746 }
1747
1748 INTEGERS { len }
1749
1750 FUNCTION {chop.word}
1751 { 's :=
1752 'len :=
1753 s #1 len substring$ =
1754 { s len #1 + global.max$ substring$ }
1755 's
1756 if$
1757 }
1758
1759 FUNCTION {sort.format.names} % from trunc-auth.bst
1760 { 's :=
1761 #0 'nameptr :=
1762 ""
1763 s num.names$ 'numnames :=
1764 numnames max.names > % from trunc-auth.bst
1765 { trunc.num 'finalnamenum := } % truncate in this case
1766 { numnames 'finalnamenum := }
1767 if$
1768 { nameptr finalnamenum < }
1769 { nameptr #1 + 'nameptr :=
1770 nameptr #1 >
1771 { " " * }
1772 'skip$
1773 if$
1774 s nameptr "{vv{ } }{ll{ }}{ f{ }}{ jj{ }}" format.name$ 't :=
1775 nameptr finalnamenum <
1776 { t sortify * }
1777 { numnames max.names >
1778 { sort.trunc.string * }
1779 { t "others" =
1780 { "et al" * }
1781 { t sortify * }
1782 if$
1783 }
1784 if$
1785 }
1786 if$
1787 }
1788 while$
1789 }
1790
1791 FUNCTION {sort.format.title}
1792 { 't :=
1793 "A " #2
1794 "An " #3
1795 "The " #4 t chop.word
1796 chop.word
1797 chop.word
1798 sortify
1799 #1 global.max$ substring$
1800 }
1801
1802 FUNCTION {author.sort}
1803 { author empty$
1804 { key empty$
1805 { "to sort, need author or key in " cite$ * warning$
1806 ""
1807 }
1808 { key sortify }
1809 if$
1810 }
1811 { author sort.format.names }
1812 if$
1813 }
1814
1815 FUNCTION {author.editor.sort}
1816 { author empty$
1817 { editor empty$
1818 { key empty$
1819 { "to sort, need author, editor, or key in " cite$ * warning$
1820 ""
1821 }
1822 { key sortify }
1823 if$
1824 }
1825 { editor sort.format.names }
1826 if$
1827 }
1828 { author sort.format.names }
1829 if$
1830 }
1831
1832 FUNCTION {author.organization.sort}
1833 { author empty$
1834 { organization empty$
1835 { key empty$
1836 { "to sort, need author, organization, or key in " cite$ * warning$
1837 ""
1838 }
1839 { key sortify }
1840 if$
1841 }
1842 { "The " #4 organization chop.word sortify }
1843 if$
1844 }
1845 { author sort.format.names }
1846 if$
1847 }
1848
1849 FUNCTION {editor.organization.sort}
1850 { editor empty$
1851 { organization empty$
1852 { key empty$
1853 { "to sort, need editor, organization, or key in " cite$ * warning$
1854 ""
1855 }
1856 { key sortify }
1857 if$
1858 }
1859 { "The " #4 organization chop.word sortify }
1860 if$
1861 }
1862 { editor sort.format.names }
1863 if$
1864 }
1865
1866 FUNCTION {presort}
1867 { key empty$
1868 {
1869 type$ "book" =
1870 type$ "inbook" =
1871 or
1872 'author.editor.sort
1873 { type$ "proceedings" =
1874 'editor.organization.sort
1875 { type$ "manual" =
1876 { author.organization.sort }
1877 { type$ "online" =
1878 type$ "misc" =
1879 or
1880 type$ "webpage" =
1881 or
1882 type$ "software" =
1883 or
1884 { author.editor.sort }
1885 { author.sort }
1886 if$ % online|misc|webpage|software
1887 }
1888 if$ % manual
1889 }
1890 if$ % proceedings
1891 }
1892 if$ % book|inbook
1893 }
1894 {
1895 % key is non-empty, use it.
1896 % "sorting by key " key * " in " * cite$ * warning$
1897 key sortify
1898 }
1899 if$ % key
1900 " "
1901 *
1902 year field.or.null sortify
1903 *
1904 " "
1905 *
1906 title field.or.null
1907 sort.format.title
1908 *
1909 #1 entry.max$ substring$
1910 'sort.key$ :=
1911 }
1912
1913 ITERATE {presort}
1914
1915 SORT
1916
1917 STRINGS { longest.label }
1918
1919 INTEGERS { number.label longest.label.width }
1920
1921 FUNCTION {initialize.longest.label}
1922 { "" 'longest.label :=
1923 #1 'number.label :=
1924 #0 'longest.label.width :=
1925 }
1926
1927 FUNCTION {longest.label.pass}
1928 { number.label int.to.str$ 'label :=
1929 number.label #1 + 'number.label :=
1930 label width$ longest.label.width >
1931 { label 'longest.label :=
1932 label width$ 'longest.label.width :=
1933 }
1934 'skip$
1935 if$
1936 }
1937
1938 EXECUTE {initialize.longest.label}
1939
1940 ITERATE {longest.label.pass}
1941
1942 FUNCTION {begin.bib}
1943 { preamble$ empty$
1944 'skip$
1945 { preamble$ write$ newline$ }
1946 if$
1947 "\begin{thebibliography}{" longest.label * "}" * write$ newline$
1948 }
1949
1950 EXECUTE {begin.bib}
1951
1952 EXECUTE {init.urlbst.variables} % urlbst
1953 EXECUTE {init.state.consts}
1954
1955 ITERATE {call.type$}
1956
1957 FUNCTION {end.bib}
1958 { newline$
1959 "\end{thebibliography}" write$ newline$
1960 }
1961
1962 EXECUTE {end.bib}