]> code.communitydata.science - rises_declines_wikia_code.git/blob - paper_source/SIGCHI-Reference-Format.bst
add copy of the GPL
[rises_declines_wikia_code.git] / paper_source / SIGCHI-Reference-Format.bst
1 %%% -*-BibTeX-*-
2 %%% ====================================================================
3 %%%  @BibTeX-style-file{
4 %%%     author          = "Nelson H. F. Beebe, Boris Veytsman and Gerald Murray",
5 %%%     version         = "1.00",
6 %%%     date            = "18 January 2012",
7 %%%     time            = "11:48 EST",
8 %%%     filename        = "ACM-Reference-Format-Journals.bst",
9 %%%     address         = "University of Utah
10 %%%                        Department of Mathematics, 110 LCB
11 %%%                        155 S 1400 E RM 233
12 %%%                        Salt Lake City, UT 84112-0090
13 %%%                        USA",
14 %%%     telephone       = "+1 801 581 5254",
15 %%%     FAX             = "+1 801 581 4148",
16 %%%     URL             = "http://www.math.utah.edu/~beebe",
17 %%%     checksum        = "available here: http://www.acm.org/publications/latex_style/CRC-journals.txt"
18 %%%     email           = "beebe@math.utah.edu, beebe@acm.org,
19 %%%                        beebe@computer.org, borisv@lk.net, murray@hq.acm.org", 
20 %%%     codetable       = "ISO/ASCII",
21 %%%     keywords        = "ACM Transactions bibliography style; BibTeX",
22 %%%     license         = "public domain",
23 %%%     supported       = "yes",
24 %%%     abstract        = "",
25 %%%     docstring       = "The checksum field, above, is produced by WinMD5Free (v1.20) 
26 %%%                        available from http://www.winmd5.com/?rid=winmd5,"
27 %%%  }
28 %%% ====================================================================
29
30 % "SIGCHI Format" BibTeX style, Forked from ACM-Reference-Format-Journals.bst
31 %  Modifications 13-FEBURARY-2015 (David Ayman Shamma)
32
33 % "ACM Transactions" BibTeX style, ACM-Reference-Format-Journals.bst
34 %  for BibTeX version 0.99c, LaTeX version 3.141
35 %  ACM extensions with code cleaned up, extended, and debugged 10--15-Nov-2008
36 %  Revised 17-APRIL-2008 (Nelson)
37 %  Revised 13-MARCH-2011 (Boris/Gerry)
38 %  Revised 23-MARCH-2011 (Boris/Gerry)
39 %  Revised 27-MARCH-2011 (Boris/Gerry)
40 %  Revised 15-APRIL-2011 (Boris/Gerry)
41 %  Revised 27-SEPTEMBER-2011 (Boris)
42 %
43 %
44 % History (by Nelson)
45 %
46 % Based on 'acmtrans' (for ACM Journals)
47 % Date: 28th April 2008
48 %
49 % 1. Avoid 'repeating' the 'month' values.
50 % 2. Avoid incorrectly italicizing the volume number.
51 % 3. Avoid non italicizing certain titles (book, inproceedings etc).
52 % 4. NO series if there is NO volume.
53 % 5. Sorting of reference with first surname.
54 % 6. Article no added for Inproceedings.
55 %
56 % Date: 07th May 2008
57 %
58 % 1. Abbreviation list added
59 %
60 %   Citation format: [author-last-name year]
61 %             [author-last-name and author-last-name year]
62 %             [author-last-name, author-last-name, and author-last-name year]
63 %             [author-last-name et al. year]
64 %             [author-last-name]
65 %             author-last-name [year]
66 %             [author-last-name and author-last-name]
67 %             [author-last-name et al.]
68 %             [year] or [year,year]
69 %             year or year,year
70 %
71 %   Reference list ordering: alphabetical by author or whatever passes
72 %    for author in the absence of one.
73 %
74 % Features of the old acmtrans.bst:
75 % =================================
76 %
77 % - all authors appear last name first.
78 % - all pages are listed xx-xx, (no pp.) and are at the end of the reference
79 % - publishers are identified as publisher, address
80 % - conferences papers (inproceedings) may give city of conference,
81 %   date of conference, and journal that the proceedings appear in.
82 % - months abbreviated to max four letters (eg. Mar.)
83 % - volume of a series indicated after the title of the series
84 % - editors appear after edited title and are identified by a trailing "Eds."
85 %   not in parentheses.  Editor names are not given in small caps.
86 %   (unless there is no author line)
87 % - names terminated with a period even if there is no first name.
88 % - editions are indicated trailing after the work, not in parentheses.
89 % - "et al." citations have a protected period to avoid bad spacing (jrh)
90 % - "address" required when publisher given
91 % - series (roman) and volume are in a sentence separate from (book-)title
92 %
93 %
94 % Features of chicago.bst:
95 % =======================
96 %
97 % - full names used in citations, but abbreviated citations are available
98 %   (see above)
99 % - if an entry has a "month", then the month and year are also printed
100 %   as part of that bibitem.
101 % - all conjunctions use "and" instead of "\&"
102 % - major modification from Chicago Manual of Style (13th ed.) is that
103 %   only the first author in a reference appears last name first-
104 %   additional authors appear as J. Q. Public.
105 % - pages are listed as "pp. xx-xx" in all entry types except
106 %   article entries.
107 % - book, inbook, and manual use "location: publisher" (or organization)
108 %   for address and publisher. All other types list publishers separately.
109 % - "pp." are used to identify page numbers for all entry types except
110 %   articles.
111 % - organization is used as a citation label if neither author nor editor
112 %   is present (for manuals).
113 % - "et al." is used for long author and editor lists, or when "others"
114 %   is used.
115 %
116 % Modifications and bug fixes from newapa.bst:
117 % ===========================================
118 %
119 %   - added month, year to bib entries if month is present
120 %   - fixed bug with In proceedings, added necessary comma after title
121 %   - all conjunctions changed to "and" from "\&"
122 %   - fixed bug with author labels in my.full.label: "et al." now is
123 %        generated when "others" is an author name
124 %   - major modification from Chicago Manual of Style (13th ed.) is that
125 %     only the first author in a reference appears last name first-
126 %     additional authors appear as J. Q. Public.
127 %   - pages are listed as "pp. xx-xx" in all entry types except
128 %     article entries. Unnecessary (IMHO) "()" around page numbers
129 %     were removed, and page numbers now don't end with a period.
130 %   - created chicago.sty for use with this bibstyle (required).
131 %   - fixed bugs in FUNCTION {format.vol.num.pages} for missing volume,
132 %     number, and /or pages. Renamed to format.journal.volume.number.
133 %   - fixed bug in formatting booktitles: additional period an error if
134 %     book has a volume.
135 %   - fixed bug: editors usually given redundant period before next clause
136 %     (format.editors.dot) removed.
137 %   - added label support for organizations, if both author and editor
138 %     are missing (from alpha.bst). If organization is too long, then
139 %     the key field is used for abbreviated citations.
140 %   - In proceedings or books of several volumes, no comma was written
141 %     between the "Volume x" and the page numbers (this was intentional
142 %     in newapa.bst). Fixed.
143 %   - Some journals may not have volumes/numbers, only month/year (eg.
144 %     IEEE Computer). Fixed bug in article style that assumed volume/number
145 %     was always present.
146 %
147 % Original documentation for newapa.sty:
148 % =====================================
149 %
150 % This version was made by modifying the master file made by
151 % Oren Patashnik (PATASHNIK@SCORE.STANFORD.EDU), and the 'named' BibTeX
152 % style of Peter F. Patel-Schneider.
153 %
154 % Copyright (C) 1985, all rights reserved.
155 % Copying of this file is authorized only if either
156 % (1) you make absolutely no changes to your copy, including name, or
157 % (2) if you do make changes, you name it something other than 'newapa.bst'.
158 % There are undoubtably bugs in this style.  If you make bug fixes,
159 % improvements, etc.  please let me know.  My e-mail address is:
160 %    spencer@cgrg.ohio.state.edu or 71160.3141@compuserve.com
161 %
162 % This style was made from 'plain.bst', 'named.bst', and 'apalike.bst',
163 % with lots of tweaking to make it look like APA style, along with tips
164 % from Young Ryu and Brian Reiser's modifications of 'apalike.bst'.
165 %
166 %
167 % Start of ACM-Reference-Format-Journals.bst
168 %
169 % Note: Many of the new bibentry 'fields' will only work with the 
170 % 'ACM-Reference-Format-Journals.bst' file. Legacy .bib files (which will, in all probability,
171 % NOT contain these new fields) will _still_ work with the ACM-Reference-Format-Journals.bst.
172
173 %
174 ENTRY
175   { address
176     advisor
177     author
178     booktitle
179     chapter
180     city        % jtb: added
181     date        % jtb: added
182     edition
183     editor
184     howpublished
185     institution
186     journal
187     key
188     month
189     note
190     number
191     organization
192     pages
193     publisher
194     school
195     series
196     title
197     type
198     volume
199     year
200         % New keys recognized 
201         issue         % UTAH: used in, e.g., ACM SIGSAM Bulletin and ACM Communications in Computer Algebra
202         articleno
203         day           % UTAH: needed for newspapers, weeklies, bi-weeklies
204         doi           % UTAH
205         url           % UTAH
206         bookpages     % UTAH
207         numpages
208         lastaccessed  % UTAH: used only for @Misc{...}
209         coden         % UTAH
210         isbn          % UTAH
211         isbn-13       % UTAH
212         issn          % UTAH
213         lccn          % UTAH
214   }
215   {}
216   { label.year extra.label sort.year sort.label }
217
218 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
219
220 INTEGERS { show-isbn-10-and-13 }  % initialized below in begin.bib
221
222 INTEGERS { nameptr namesleft numnames }
223
224 INTEGERS { multiresult }
225
226 INTEGERS { len }
227
228 INTEGERS { last.extra.num }
229
230 STRINGS { s t t.org u }
231
232 STRINGS { last.label next.extra }
233
234 STRINGS { p1 p2 p3 page.count }
235
236 FUNCTION { dump.stack.1 }
237 {
238     duplicate$ "STACK[top] = [" swap$ * "]" * warning$
239 }
240
241 FUNCTION { dump.stack.2 }
242 {
243     duplicate$ "STACK[top  ] = [" swap$ * "]" * warning$
244     swap$
245     duplicate$ "STACK[top-1] = [" swap$ * "]" * warning$
246     swap$
247 }
248
249 FUNCTION { empty.or.unknown }
250 {
251   %% Examine the top stack entry, and push 1 if it is empty, or
252   %% consists only of whitespace, or is a string beginning with two
253   %% queries (??), and otherwise, push 0.
254   %%
255   %% This function provides a replacement for empty$, with the
256   %% convenient feature that unknown values marked by two leading
257   %% queries are treated the same as missing values, and thus, do not
258   %% appear in the output .bbl file, and yet, their presence in .bib
259   %% file(s) serves to mark values which are temporarily missing, but
260   %% are expected to be filled in eventually once more data is
261   %% obtained.  The TeX User Group and BibNet bibliography archives
262   %% make extensive use of this practice.
263   %%
264   %% An empty string cannot serve the same purpose, because just as in
265   %% statistics data processing, an unknown value is not the same as an
266   %% empty value.
267   %%
268   %% At entry: stack = ... top:[string]
269   %% At exit:  stack = ... top:[0 or 1]
270
271   duplicate$ empty$
272     { pop$ #1 }
273     { #1 #2 substring$ "??" = }
274   if$
275 }
276
277 FUNCTION { writeln }
278 {
279   %% In BibTeX style files, the sequences
280   %%
281   %%     ... "one" "two" output
282   %%     ... "one" "two" output.xxx
283   %%
284   %% ship "one" to the output file, possibly following by punctuation,
285   %% leaving the stack with
286   %%
287   %%     ... "two"
288   %%
289   %% There is thus a one-string lag in output processing that must be
290   %% carefully handled to avoid duplicating a string in the output
291   %% file.  Unless otherwise noted, all output.xxx functions leave
292   %% just one new string on the stack, and that model should be born
293   %% in mind when reading or writing function code.
294   %%
295   %% BibTeX's asynchronous buffering of output from strings from the
296   %% stack is confusing because newline$ bypasses the buffer.  It
297   %% would have been so much easier for newline to be a character
298   %% rather than a state of the output-in-progress.
299   %%
300   %% The documentation in btxhak.dvi is WRONG:  it says
301   %%
302   %%    newline$ Writes onto the bbl file what's accumulated in the
303   %%             output buffer. It writes a blank line if and only
304   %%             if the output buffer is empty. Since write$ does
305   %%             reasonable line breaking, you should use this
306   %%             function only when you want a blank line or an
307   %%             explicit line break.
308   %%
309   %%    write$   Pops the top (string) literal and writes it on the
310   %%             output buffer (which will result in stuff being
311   %%             written onto the bbl file when the buffer fills
312   %%             up).
313   %%
314   %% Examination of the BibTeX source code shows that write$ does
315   %% indeed behave as claimed, but newline$ sends a newline character
316   %% directly to the output file, leaving the stack unchanged.  The
317   %% first line "Writes onto ... buffer." is therefore wrong.
318   %%
319   %% The original BibTeX style files almost always use "write$ newline$"
320   %% in that order, so it makes sense to hide that pair in a private
321   %% function like this one, named after a statement in Pascal,
322   %% the programming language embedded in the BibTeX Web program.
323
324   write$                % output top-of-stack string
325   newline$              % immediate write of newline (not via stack)
326 }
327
328 FUNCTION { init.state.consts }
329 {
330   #0 'before.all :=
331   #1 'mid.sentence :=
332   #2 'after.sentence :=
333   #3 'after.block :=
334 }
335
336 FUNCTION { output.nonnull }
337 { % Stack in: ... R S T  Stack out: ... R T   File out: S<comma><space>
338   's :=
339   output.state mid.sentence =
340     {
341       ", " * write$
342     }
343     {
344       output.state after.block =
345         {
346           add.period$ writeln
347           "\newblock " write$
348         }
349         {
350           output.state before.all =
351             {
352               write$
353             }
354             {
355               add.period$ " " * write$
356             }
357           if$
358         }
359       if$
360       mid.sentence 'output.state :=
361     }
362   if$
363   s
364 }
365
366 FUNCTION { output.nonnull.dot.space }
367 { % Stack in: ... R S T  Stack out: ... R T   File out: S<dot><space>
368   's :=
369   output.state mid.sentence =           % { "<DEBUG output.nonnull.dot.space>. " * write$ }
370     {
371       ". " * write$
372     }
373     {
374       output.state after.block =
375         {
376           add.period$ writeln "\newblock " write$
377         }
378         {
379           output.state before.all =
380             {
381               write$
382             }
383             {
384               add.period$ " " * write$
385             }
386           if$
387         }
388       if$
389       mid.sentence 'output.state :=
390     }
391   if$
392   s
393 }
394
395 FUNCTION { output.nonnull.remove }
396 { % Stack in: ... R S T  Stack out: ... R T   File out: S<space>
397   's :=
398   output.state mid.sentence =
399     {
400       " " * write$
401     }
402     {
403       output.state after.block =
404         {
405           add.period$ writeln "\newblock " write$
406         }
407         {
408           output.state before.all =
409             {
410               write$
411             }
412             {
413               add.period$ " " * write$
414             }
415           if$
416         }
417       if$
418       mid.sentence 'output.state :=
419     }
420   if$
421   s
422 }
423
424 FUNCTION { output.nonnull.removenospace }
425 { % Stack in: ... R S T  Stack out: ... R T   File out: S
426   's :=
427   output.state mid.sentence =
428     {
429       "" * write$
430     }
431     {
432       output.state after.block =
433         {
434           add.period$ writeln "\newblock " write$
435         }
436         {
437           output.state before.all =
438             {
439               write$
440             }
441             {
442               add.period$ " " * write$
443             }
444           if$
445         }
446       if$
447       mid.sentence 'output.state :=
448     }
449   if$
450   s
451 }
452
453 FUNCTION { output }
454 { % discard top token if empty, else like output.nonnull
455   duplicate$ empty.or.unknown
456     'pop$
457     'output.nonnull
458   if$
459 }
460
461 FUNCTION { output.dot.space }
462 { % discard top token if empty, else like output.nonnull.dot.space
463   duplicate$ empty.or.unknown
464     'pop$
465     'output.nonnull.dot.space
466   if$
467 }
468
469 FUNCTION { output.removenospace }
470 { % discard top token if empty, else like output.nonnull.removenospace
471   duplicate$ empty.or.unknown
472     'pop$
473     'output.nonnull.removenospace
474   if$
475 }
476
477 FUNCTION { output.check }
478 { % like output, but warn if key name on top-of-stack is not set
479   't :=
480   duplicate$ empty.or.unknown
481     { pop$ "empty " t * " in " * cite$ * warning$ }
482     'output.nonnull
483   if$
484 }
485
486 FUNCTION { output.check.dot.space }
487 { % like output.dot.space, but warn if key name on top-of-stack is not set
488   't :=
489   duplicate$ empty.or.unknown
490     { pop$ "empty " t * " in " * cite$ * warning$ }
491     'output.nonnull.dot.space
492   if$
493 }
494
495 FUNCTION { fin.block }
496 { % functionally, but not logically, identical to fin.entry
497    add.period$
498    writeln
499 }
500
501 FUNCTION { fin.entry }
502 {
503    add.period$
504    writeln
505 }
506
507 FUNCTION { new.sentence }
508 { % update sentence state, with neither output nor stack change
509   output.state after.block =
510     'skip$
511     {
512       output.state before.all =
513         'skip$
514         { after.sentence 'output.state := }
515       if$
516     }
517   if$
518 }
519
520 FUNCTION { fin.sentence }
521 {
522    add.period$
523    write$
524    new.sentence
525    ""
526 }
527
528 FUNCTION { new.block }
529 {
530   output.state before.all =
531     'skip$
532     { after.block 'output.state := }
533   if$
534 }
535
536 FUNCTION { output.coden }       % UTAH
537 { % output non-empty CODEN as one-line sentence (stack untouched)
538   coden empty.or.unknown
539     { }
540     { "\showCODEN{" coden * "}" * writeln }
541   if$
542 }
543
544 FUNCTION { format.articleno }
545 {
546   articleno empty.or.unknown
547      { "" }
548      {
549         numpages empty.or.unknown
550           { "articleno field, but no numpages field, in " cite$ * warning$ }
551           { }
552         if$
553         "Article " articleno *
554      }
555   if$
556 }
557
558 FUNCTION { format.year }
559 { % push year string or "????" onto output stack
560   %% Because year is a mandatory field, we always force SOMETHING
561   %% to be output
562   year empty.or.unknown
563     { "????" }
564     { year }
565   if$
566 }
567
568 FUNCTION { format.day.month }
569 { % push "day month " or "month " or "" onto output stack
570   day empty.or.unknown
571     {
572       month empty.or.unknown
573         { "" }
574         { month " " *}
575       if$
576     }
577     {
578       month empty.or.unknown
579         { "" }
580         { day " " * month * " " *}
581       if$
582     }
583   if$
584 }
585
586 FUNCTION { format.day.month.year }     % UTAH
587 { % if month is empty, push "" else push "(MON.)" or "(DD MON.)"
588   % Needed for frequent periodicals: 2008. ... New York Times C-1, C-2, C-17 (23 Oct.)
589   % acm-*.bst addition: prefix parenthesized date string with
590   % ", Article nnn "
591   articleno empty.or.unknown
592     { "" }
593     { ", " format.articleno * }
594   if$
595   " (" * format.day.month * format.year * ")" *
596 }
597
598 FUNCTION { output.day.month.year }     % UTAH
599 { % if month is empty value, do nothing; else output stack top and
600   % leave with new top string "(MON.)" or "(DD MON.)"
601   % Needed for frequent periodicals: 2008. ... New York Times C-1, C-2, C-17 (23 Oct.)
602   format.day.month.year
603   output.nonnull.remove
604 }
605
606 FUNCTION { strip.doi } % UTAH
607 { % Strip any Web address prefix to recover the bare DOI, leaving the
608   % result on the output stack, as recommended by CrossRef DOI
609   % documentation.
610   % For example, reduce "http://doi.acm.org/10.1145/1534530.1534545" to
611   % "10.1145/1534530.1534545".  That is later typeset and displayed as
612   % doi:10.1145/1534530.1534545 as the LAST item in the reference list
613   % entry.  Publisher Web sites wrap this with a suitable link to a real
614   % URL to resolve the DOI, and the master http://dx.doi.org/ address is
615   % preferred, since publisher-specific URLs can disappear in response
616   % to economic events.  All journals are encouraged by the DOI
617   % authorities to use that typeset format and link procedures for
618   % uniformity across all publications that include DOIs in reference
619   % lists.
620   % The numeric prefix is guaranteed to start with "10.", so we use
621   % that as a test.
622   doi #1 #3 substring$ "10." =
623     { doi }
624     {
625       doi #1 #7 substring$ "http://" =
626         {
627             doi #8 doi text.length$ #7 - substring$ 't := % get modifiable copy of rest of DOI
628
629             "INTERNAL STYLE-FILE ERROR" 's :=
630
631             % search for next "/" and assign its suffix to s
632
633             { t text.length$ }
634             {
635               t #1 #1 substring$ "/" =
636                 {
637                   % save rest of string as true DOI (should be 10.xxxx/yyyy)
638                   t #2 t text.length$ #1 - substring$ 's :=
639                   "" 't :=    % empty string t terminates the loop
640                 }
641                 {
642                   % discard first character and continue loop: t <= substring(t,2,last)
643                   t #2 t text.length$ #1 - substring$ 't :=
644                 }
645               if$
646             }
647             while$
648
649             % check for valid DOI (should be 10.xxxx/yyyy)
650             s #1 #3 substring$ "10." =
651               { }
652               { "unrecognized DOI substring " s * " in DOI value [" * doi * "]" * warning$ }
653             if$
654
655             s   % push the stripped DOI on the output stack
656
657         }
658         {
659           "unrecognized DOI value [" doi * "]" * warning$
660           doi   % push the unrecognized original DOI on the output stack
661         }
662       if$
663     }
664   if$
665 }
666
667 %
668 % Change by BV: added standard prefix to URL
669 %
670 FUNCTION { output.doi } % UTAH
671 { % output non-empty DOI as one-line sentence (stack untouched)
672   doi empty.or.unknown
673     { }
674     {
675       %% NB: We want URLs at beginning of line to reduce likelihood of
676       %% BibTeX's nasty line wrapping after column 79, which then requires
677       %% manual (or automated) editing of the .bbl file to repair.
678       %% The \url{} macro strips percent-newlines, and is thus safe in
679       %% the presence of the line wrapping, but \path|...| and
680       %% \verb|...| do not.
681       "\showDOI{%" writeln
682       "\url{http://dx.doi.org/" strip.doi * "}}" * writeln
683     }
684   if$
685 }
686
687 FUNCTION { output.isbn }                % UTAH
688 { % output non-empty ISBN-10 and/or ISBN-13 as one-line sentences (stack untouched)
689   show-isbn-10-and-13
690     {
691       %% show both 10- and 13-digit ISBNs
692       isbn empty.or.unknown
693         { }
694         {
695           "\showISBNx{" isbn * "}" * writeln
696         }
697       if$
698       isbn-13 empty.or.unknown
699         { }
700         {
701           "\showISBNxiii{" isbn-13 * "}" * writeln
702         }
703       if$
704     }
705     {
706       %% show 10-digit ISBNs only if 13-digit ISBNs not available
707       isbn-13 empty.or.unknown
708         {
709           isbn empty.or.unknown
710             { }
711             {
712               "\showISBNx{" isbn * "}" * writeln
713             }
714           if$
715         }
716         {
717           "\showISBNxiii{" isbn-13 * "}" * writeln
718         }
719       if$
720     }
721   if$
722 }
723
724 FUNCTION { output.issn } % UTAH
725 { % output non-empty ISSN as one-line sentence (stack untouched)
726   issn empty.or.unknown
727     { }
728     { "\showISSN{" issn * "}" * writeln }
729   if$
730 }
731
732 FUNCTION { output.issue }
733 { % output non-empty issue number as a one-line sentence (stack untouched)
734   issue empty.or.unknown
735     { }
736     { "Issue " issue * "." * writeln }
737   if$
738 }
739
740 FUNCTION { output.lccn } % UTAH
741 { % return with stack untouched
742   lccn empty.or.unknown
743     { }
744     { "\showLCCN{" lccn * "}" * writeln }
745   if$
746 }
747
748 FUNCTION { output.note } % UTAH
749 { % return with stack empty
750   note empty.or.unknown
751     { }
752     { "\shownote{" note add.period$ * "}" * writeln }
753   if$
754 }
755
756 FUNCTION { output.note.check } % UTAH
757 { % return with stack empty
758   note empty.or.unknown
759     { "empty note in " cite$ * warning$ }
760     { "\shownote{" note add.period$ * "}" * writeln }
761   if$
762 }
763
764 %
765 % Changes by BV 2011/04/15.  Do not output
766 % url if doi is defined
767 %
768 FUNCTION { output.url } % UTAH
769 { % return with stack untouched
770   % output URL and associated lastaccessed fields
771   doi empty.or.unknown
772   {
773     url empty.or.unknown
774       { }
775       {
776           %% NB: We want URLs at beginning of line to reduce likelihood of
777           %% BibTeX's nasty line wrapping after column 79, which would require
778           %% manual (or automated) editing of the .bbl file to repair.  However,
779           %% the \url{} macro handles the unwrapping job automatically.
780           "\showURL{%" writeln
781           lastaccessed empty.or.unknown
782             { "" }
783             { "Retrieved " lastaccessed * " from " * }
784           if$
785
786           %% The URL field may contain a semicolon-separated list of Web
787           %% addresses, and we locate and wrap each of them in \url{...}.
788           %% The simplistic approach of putting the entire list into the
789           %% macro argument is that the semicolons are typeset in a
790           %% typewriter font, and no space follows them.
791           %%
792           %% We therefore replace the original code
793           %%    "\url{" * url * "}}" * writeln
794           %% with this character-at-a-time loop:
795
796           "\url{" *
797
798           url 't :=                       % get modifiable copy of URL list
799
800           { t text.length$ }
801           {
802             t #1 #1 substring$ ";" =
803               {                         % then split argument at separator
804                 "};" * writeln
805                 "\url{"
806               }
807               {                         % else concatenate nonblank character to argument
808                 t #1 #1 substring$ " " =
809                   { }
810                   { t #1 #1 substring$ * }
811                 if$
812               }
813             if$
814
815             t #2 t text.length$ #1 - substring$ 't :=
816           }
817           while$
818
819           "}}" * writeln
820       }
821     if$
822   }
823   { }
824   if$
825 }
826
827 FUNCTION { output.year.check }
828 { % warn if year empty, else output top string and leave " YEAR<label>" on stack in mid-sentence
829   year empty.or.unknown
830      { "empty year in " cite$ * warning$ }
831      { write$
832         " " year * extra.label *
833        mid.sentence 'output.state :=
834      }
835   if$
836 }
837
838 FUNCTION { not }
839 {
840     { #0 }
841     { #1 }
842   if$
843 }
844
845 FUNCTION { and }
846 {
847     'skip$
848     { pop$ #0 }
849   if$
850 }
851
852 FUNCTION { or }
853 {
854    { pop$ #1 }
855     'skip$
856   if$
857 }
858
859 FUNCTION { le }
860 {
861   %% test whether first number is less than or equal to second number
862   %% stack in:  n1 n2
863   %% stack out: if n1 <= n2 then 1 else 0
864
865   %% "DEBUG: le " cite$ * warning$
866   > { #0 } { #1 } if$
867 }
868
869 FUNCTION { ge }
870 {
871   %% test whether first number is greater than or equal to second number
872   %% stack in:  n1 n2
873   %% stack out: if n1 >= n2 then 1 else 0
874
875   %% "DEBUG: ge " cite$ * warning$
876   < { #0 } { #1 } if$
877 }
878
879 FUNCTION { is.leading.digit }
880 {
881   %% test whether first character of string is a digit
882   %% stack in:  string
883   %% stack out: if first-char-is-digit then 1 else 0
884
885   #1 #1 substring$                      % replace string by string[1:1]
886   duplicate$                            % string[1:1] string[1:1]
887   chr.to.int$
888   "0" chr.to.int$ swap$ le              % "0" <= string[1:1] --> 0-or-1
889   swap$                                 % 0-or-1 string[1:1]
890   chr.to.int$
891   "9" chr.to.int$ le                    % string[1:1} <= "9" --> 0-or-1
892   and
893 }
894
895 FUNCTION { skip.digits }
896 {
897   %% skip over leading digits in string
898   %% stack in:  string
899   %% stack out: rest-of-string leading-digits
900
901   %% "DEBUG: enter skip.digits " cite$ * warning$
902
903   %% dump.stack.1
904
905   duplicate$
906   't :=
907   't.org :=
908   "" 'u :=
909
910   { t text.length$ }
911   {
912     %% "=================DEBUG: skip.digits   t = [" t * "]" * warning$
913     t is.leading.digit
914       { t #2 t text.length$ #1 - substring$ }
915       {
916         t 'u :=
917         ""
918       }
919     if$
920     't :=
921   }
922   while$
923
924   u                                                             % rest of string
925   t.org #1 t.org text.length$ u text.length$ - substring$       % leading digits
926
927   %% "DEBUG: t.org = [" t.org * "]" * warning$
928   %% "DEBUG: u     = [" u * "]" * warning$
929
930   %% dump.stack.2
931
932   %% "DEBUG: leave skip.digits " cite$ * warning$
933 }
934
935 FUNCTION { skip.nondigits }
936 {
937   %% skip over leading nondigits in string
938   %% stack in:  string
939   %% stack out: rest-of-string
940
941   %% "DEBUG: enter skip.nondigits " cite$ * warning$
942
943   't :=
944   "" 'u :=
945
946   { t text.length$ }
947   {
948     %% "=================DEBUG: skip.nondigits   t = [" t * "]" * warning$
949     t is.leading.digit
950       {
951         t 'u :=
952         ""
953       }
954       { t #2 t text.length$ #1 - substring$ }
955     if$
956     't :=
957   }
958   while$
959
960   u                     % rest of string
961
962   %% dump.stack.1
963   %% "DEBUG: leave skip.nondigits " cite$ * warning$
964 }
965
966 FUNCTION { parse.next.number }
967 {
968   %% stack in:  string
969   %% stack out: rest-of-string next-numeric-part-of-string
970   %% Example:
971   %% stack in:  "123:1--123:59"
972   %% stack out: ":1--123:59" "123"
973
974   's :=
975   s skip.nondigits 's :=
976   s skip.digits
977 }
978
979 FUNCTION { reduce.pages.to.page.count }
980 {
981   %% Stack in:  arbitrary-and-unused
982   %% Stack out: unchanged
983   %%
984   %% For the new-style pagination with article number and numpages or
985   %% pages, we expect to have BibTeX entries containing something like
986   %%     articleno = "17",
987   %%     pages     = "1--23",
988   %% with output "Article 17, 23 pages",
989   %% or
990   %%     articleno = "17",
991   %%     numpages  = "23",
992   %% with output "Article 17, 23 pages",
993   %% or
994   %%     articleno = "17",
995   %%     pages     = "17:1--17:23",
996   %% with output "Article 17, 23 pages",
997   %%
998   %% If articleno is missing or empty, then we should output "1--23",
999   %% "23" (with a warning of a missing articleno), or "17:1--17:23",
1000   %% respectively.
1001
1002   %% "DEBUG: enter reduce.pages.to.page.count " cite$ * warning$
1003
1004   %% "DEBUG: pages = [" pages * "]" * warning$
1005
1006   pages
1007   parse.next.number 'p1 :=
1008   parse.next.number 'p2 :=
1009   parse.next.number 'p3 :=
1010   parse.next.number 'page.count :=
1011
1012   duplicate$
1013   empty.or.unknown
1014     {  }
1015     {
1016       duplicate$ "unexpected trailing garbage [" swap$ *
1017       "] after n:p1--n:p2 in pages = [" *
1018       pages *
1019       "] in " *
1020       cite$ *
1021       warning$
1022     }
1023   if$
1024
1025   pop$
1026
1027   %% "DEBUG: reduce.pages.to.page.count: "
1028   %% " p1 = " p1 * *
1029   %% " p2 = " p2 * *
1030   %% " p3 = " p3 * *
1031   %% " p4 = " page.count * *
1032   %% " in " cite$ * * warning$
1033
1034   p1 p3 =   p2 "1" =   and   numpages empty.or.unknown   and
1035     { "INFO: reduced pages = [" pages * "] to numpages = [" * page.count * "]" * warning$ }
1036     {
1037       numpages empty.or.unknown
1038         { pages }
1039         { numpages }
1040       if$
1041       'page.count :=
1042     }
1043   if$
1044
1045   p1 "1" =   p3 empty.or.unknown   and   numpages empty.or.unknown   and
1046     {
1047       p2 'page.count :=
1048       "INFO: reduced pages = [" pages * "] to numpages = [" * page.count * "]" * warning$
1049     }
1050     {
1051       numpages empty.or.unknown
1052         { pages }
1053         { numpages }
1054       if$
1055       'page.count :=
1056     }
1057   if$
1058
1059   %% "DEBUG: leave reduce.pages.to.page.count " cite$ * warning$
1060 }
1061
1062 FUNCTION { new.block.checkb }
1063 { % issue a new.block only if at least one of top two stack strings is not empty
1064   empty.or.unknown
1065   swap$ empty.or.unknown
1066   and
1067     'skip$
1068     'new.block
1069   if$
1070 }
1071
1072 FUNCTION { field.or.null }
1073 { % convert empty value to null string, else return value
1074   duplicate$ empty.or.unknown
1075     { pop$ "" }
1076     'skip$
1077   if$
1078 }
1079
1080 FUNCTION { emphasize }
1081 { % emphasize a non-empty top string on the stack (WITHOUT italic correction)
1082   duplicate$ empty.or.unknown
1083     { pop$ "" }
1084     { "{\em " swap$ * "}" * }
1085   if$
1086 }
1087
1088 FUNCTION { emphasize.with.italic.correction }
1089 { % convert empty string to null string, or emphasize with a trailing italic correction
1090   duplicate$ empty.or.unknown
1091     { pop$ "" }
1092     { "{\em " swap$ * "\/}" * }
1093   if$
1094 }
1095
1096 FUNCTION { comma }
1097 { % convert empty string to null string, or brace string and add trailing comma
1098   duplicate$ empty.or.unknown
1099     { pop$ "" }
1100     { "{" swap$ * "}," * }
1101   if$
1102 }
1103
1104 FUNCTION { format.names }
1105 {
1106   % Format bibliographical entries with the first author last name first,
1107   % and subsequent authors with initials followed by last name.
1108   % All names are formatted in this routine.
1109
1110   's :=
1111   #1 'nameptr :=               % nameptr = 1;
1112   s num.names$ 'numnames :=    % numnames = num.name$(s);
1113   numnames 'namesleft :=
1114     { namesleft #0 > }
1115     { nameptr #1 =
1116         %NO: BAD ORDER: {"{" s nameptr "{ff~}{ll}{, jj}{, vv}" format.name$ * "}" * 't := }
1117         %NO: BAD ORDER: {"{" s nameptr "{ff~}{ll}{, jj}{, vv}" format.name$ * "}" * 't := }
1118         {"{" s nameptr "{ff }{vv }{ll}{, jj}" format.name$ * "}" * 't := }
1119         {"{" s nameptr "{ff }{vv }{ll}{, jj}" format.name$ * "}" * 't := }
1120       if$
1121       nameptr #1 >
1122         {
1123           namesleft #1 >
1124             { ", " * t * }
1125             {
1126               numnames #2 >
1127                 { "," * }
1128                 'skip$
1129               if$
1130               t "{\sc others}" =
1131                 { " {et~al\mbox{.}}" * } % jrh: avoid spacing problems
1132                 { " {and} " * t * } % from Chicago Manual of Style
1133               if$
1134             }
1135           if$
1136         }
1137         't
1138       if$
1139       nameptr #1 + 'nameptr :=          % nameptr += 1;
1140       namesleft #1 - 'namesleft :=      % namesleft =- 1;
1141     }
1142   while$
1143 }
1144
1145 FUNCTION { my.full.label }
1146 {
1147   's :=
1148   #1 'nameptr :=               % nameptr = 1;
1149   s num.names$ 'numnames :=    % numnames = num.name$(s);
1150   numnames 'namesleft :=
1151     { namesleft #0 > }
1152
1153     { s nameptr "{vv~}{ll}" format.name$ 't :=  % get the next name
1154       nameptr #1 >
1155         {
1156           namesleft #1 >
1157             { ", " * t * }
1158             {
1159               numnames #2 >
1160                 { "," * }
1161                 'skip$
1162               if$
1163               t "others" =
1164                 { " et~al\mbox{.}" * } % jrh: avoid spacing problems
1165                 { " and " * t * } % from Chicago Manual of Style
1166               if$
1167             }
1168           if$
1169         }
1170         't
1171       if$
1172       nameptr #1 + 'nameptr :=          % nameptr += 1;
1173       namesleft #1 - 'namesleft :=      % namesleft =- 1;
1174     }
1175   while$
1176
1177 }
1178
1179 FUNCTION { format.names.fml }
1180 {
1181   % Format names in "familiar" format, with first initial followed by
1182   % last name. Like format.names, ALL names are formatted.
1183   % jtb: The names are NOT put in small caps
1184
1185   's :=
1186   #1 'nameptr :=               % nameptr = 1;
1187   s num.names$ 'numnames :=    % numnames = num.name$(s);
1188   numnames 'namesleft :=
1189     { namesleft #0 > }
1190
1191     {
1192       "{" s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ * "}" * 't :=
1193
1194       nameptr #1 >
1195         {
1196           namesleft #1 >
1197             { ", " * t * }
1198             {
1199               numnames #2 >
1200                 { "," * }
1201                 'skip$
1202               if$
1203               t "{others}" =
1204                 { " {et~al\mbox{.}}" * }
1205                 { " {and} " * t * }
1206               if$
1207             }
1208           if$
1209         }
1210         't
1211       if$
1212       nameptr #1 + 'nameptr :=          % nameptr += 1;
1213       namesleft #1 - 'namesleft :=      % namesleft =- 1;
1214     }
1215   while$
1216 }
1217
1218 FUNCTION { format.authors }
1219 {
1220   author empty.or.unknown
1221     { "" }
1222     { author format.names add.period$} % jtb: add period if none before
1223   if$
1224 }
1225
1226 FUNCTION { format.key }
1227 {
1228   empty.or.unknown
1229     { key field.or.null }
1230     { "" }
1231   if$
1232 }
1233
1234 FUNCTION { format.no.key }
1235 {
1236   empty.or.unknown
1237     { "" }
1238     { "" }
1239   if$
1240 }
1241
1242 FUNCTION { format.editors.fml }
1243 {
1244   % Format editor names for use in the "in" types: inbook, incollection,
1245   % inproceedings: first initial, then last names. When editors are the
1246   % LABEL for an entry, then format.editor is used which lists editors
1247   % by last name first.
1248
1249   editor empty.or.unknown
1250     { "" }
1251     {
1252       editor format.names.fml editor num.names$ #1 >
1253         { " (Eds.)" * }
1254         { " (Ed.)" * }
1255       if$
1256     }
1257   if$
1258 }
1259
1260 FUNCTION { format.editors }
1261 { % format editor names for use in labels, last names first.
1262   editor empty.or.unknown
1263     { "" }
1264     {
1265       editor format.names
1266       editor num.names$ #1 >
1267         { " (Eds.)." * }
1268         { " (Ed.)." * }
1269       if$
1270     }
1271   if$
1272 }
1273
1274 FUNCTION { format.articletitle }
1275 {
1276   title empty.or.unknown
1277     { "" }
1278     % Use this to preserve lettercase in titles:
1279     { "\showarticletitle{" title * "}" * }
1280     % Use this for downcase title style:
1281     % { \showarticletitle{" title "t" change.case$ * "}" * }
1282   if$
1283 }
1284
1285 FUNCTION { format.title }
1286 {
1287   title empty.or.unknown
1288     { "" }
1289     % Use this to preserve lettercase in titles:
1290     { title }
1291     % Use this for downcase title style:
1292     % { title "t" change.case$ }
1293   if$
1294 }
1295
1296 FUNCTION { n.dashify }
1297 {
1298   't :=
1299   ""
1300     { t empty.or.unknown not }
1301     {
1302       t #1 #1 substring$ "-" =
1303         {
1304           t #1 #2 substring$ "--" = not
1305             { "--" *
1306               t #2 global.max$ substring$ 't :=
1307             }
1308             {
1309               { t #1 #1 substring$ "-" = }
1310               {
1311                 "-" *
1312                 t #2 global.max$ substring$ 't :=
1313               }
1314               while$
1315             }
1316           if$
1317         }
1318         {
1319           t #1 #1 substring$ *
1320           t #2 global.max$ substring$ 't :=
1321         }
1322       if$
1323     }
1324   while$
1325 }
1326
1327 FUNCTION { format.btitle }
1328 {
1329   edition empty.or.unknown
1330   { title emphasize }
1331   { title empty.or.unknown
1332     { title emphasize } % jtb: what is this supposed to do ?!?
1333     { "{\em " title * "\/} (" * edition "l" change.case$ * " ed.)" * } % jtb: no parens for ed.
1334     if$
1335   }
1336   if$
1337 }
1338
1339 FUNCTION { format.emphasize.booktitle }
1340 { % push "" or "{\em booktitle}" or "{\em booktitle}, (second ed.)" on stack
1341   edition empty.or.unknown
1342     { booktitle emphasize }
1343     { booktitle empty.or.unknown
1344       { "" }
1345       { "{\em " booktitle * "} (" * edition "l" change.case$ * " ed.)" * }
1346       if$
1347     }
1348   if$
1349 }
1350
1351 FUNCTION { format.city }
1352 {
1353   % jtb: if the preceding string (the title of the conference) is non-empty,
1354   % jtb: append the location, otherwise leave empty (so as to trigger the
1355   % jtb: error message in output.check
1356
1357   duplicate$ empty.or.unknown
1358     { }
1359     {
1360       city empty.or.unknown
1361         {
1362           date empty.or.unknown
1363             { }
1364             { " (" * date * ")" * }
1365           if$
1366         }
1367         {
1368           date empty.or.unknown
1369             { " (" * city * ")" * }
1370             { " (" * city * ", " * date * ")" * }
1371           if$
1372         }
1373       if$
1374     }
1375   if$
1376 }
1377
1378 FUNCTION { tie.or.space.connect }
1379 {
1380   duplicate$ text.length$ #3 <
1381     { "~" }
1382     { " " }
1383   if$
1384   swap$ * *
1385 }
1386
1387 FUNCTION { either.or.check }
1388 {
1389   empty.or.unknown
1390     'pop$
1391     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
1392   if$
1393 }
1394
1395 FUNCTION { format.bvolume }
1396 {
1397   % jtb: If there is a series, this is added and the volume trails after it.
1398   % jtb: Otherwise, "Vol" is Capitalized.
1399
1400   volume empty.or.unknown
1401     { "" }
1402     {
1403       series empty.or.unknown
1404         { "Vol." volume tie.or.space.connect}
1405         { series ", " * "Vol." volume tie.or.space.connect *}
1406       if$
1407       "volume and number" number either.or.check
1408     }
1409   if$
1410 }
1411
1412 FUNCTION { format.bvolume.noseries }
1413 {
1414   volume empty.or.unknown
1415     { "" }
1416     {
1417       series empty.or.unknown
1418         { "Vol." volume tie.or.space.connect}
1419         { "Vol." volume tie.or.space.connect}
1420 %        { series ", " * "Vol." volume tie.or.space.connect *}
1421       if$
1422       "volume and number" number either.or.check
1423     }
1424   if$
1425 }
1426
1427 FUNCTION { format.series }
1428 {
1429   series empty.or.unknown
1430     {""}
1431     {" {\em (" * series ")}" *}
1432   if$
1433 }
1434
1435 FUNCTION { format.number.series }
1436 {
1437   volume empty.or.unknown
1438     {
1439       number empty.or.unknown
1440         {
1441           volume empty.or.unknown
1442           { "" }
1443           {
1444             series empty.or.unknown
1445               { "" }
1446               { " (" series * ")" * }
1447             if$
1448           }
1449           if$
1450         }                                       %    { series field.or.null }
1451         {
1452           output.state mid.sentence =
1453             { "Number" }                        % gnp - changed to mixed case always
1454             { "Number" }
1455           if$
1456           number tie.or.space.connect series empty.or.unknown
1457             { "there's a number but no series in " cite$ * warning$ }
1458             { " in " * series * }
1459           if$
1460         }
1461       if$
1462     }
1463     {
1464       ""
1465     }
1466   if$
1467 }
1468
1469 FUNCTION { multi.page.check }
1470 {
1471   't :=
1472   #0 'multiresult :=
1473     { multiresult not
1474       t empty.or.unknown not
1475       and
1476     }
1477     { t #1 #1 substring$
1478       duplicate$ "-" =
1479       swap$ duplicate$ "," =
1480       swap$ "+" =
1481       or or
1482     { #1 'multiresult := }
1483     { t #2 global.max$ substring$ 't := }
1484       if$
1485     }
1486   while$
1487   multiresult
1488 }
1489
1490 FUNCTION { format.pages }
1491 {
1492   pages empty.or.unknown
1493     { "" }
1494     {
1495       pages multi.page.check
1496         { pages n.dashify } % gnp - removed () % jtb: removed pp.
1497         { pages }
1498       if$
1499     }
1500   if$
1501 }
1502
1503 FUNCTION { format.pages.check.without.articleno }
1504 { %% format pages field only if articleno is absent
1505   %% Stack out: pages-specification
1506   numpages missing$ pages missing$ and
1507     { "page numbers missing in both pages and numpages fields in " cite$ * warning$ }
1508     { }
1509   if$
1510
1511   articleno empty.or.unknown
1512     {
1513       pages missing$
1514         { numpages }
1515         { format.pages }
1516       if$
1517     }
1518     { "" }
1519   if$
1520 }
1521
1522 FUNCTION { format.pages.check }
1523 {
1524   pages empty.or.unknown
1525     { "page numbers missing in " cite$ * warning$ "" }
1526     { pages n.dashify }
1527   if$
1528 }
1529
1530 FUNCTION { format.bookpages }
1531 {
1532   bookpages empty.or.unknown
1533     { "" }
1534     { bookpages "book pages" tie.or.space.connect }
1535   if$
1536 }
1537
1538 FUNCTION { format.named.pages }
1539 {
1540   pages empty.or.unknown
1541     { "" }
1542     { format.pages "pages" tie.or.space.connect }
1543   if$
1544 }
1545
1546 %
1547 % Changed by Boris Veytsman, 2011-03-13
1548 % Now the word "pages" is printed even if
1549 % there field pages is not empty.
1550 %
1551
1552 FUNCTION { format.page.count }
1553 {
1554   page.count empty.or.unknown
1555     { "" }
1556     {
1557       articleno empty.or.unknown
1558         { "numpages field, but no articleno field, in " cite$ * warning$ }
1559         { }
1560       if$
1561       page.count "pages" tie.or.space.connect
1562     }
1563   if$
1564 }
1565
1566 FUNCTION { format.articleno.numpages }
1567 {
1568   %% There are seven possible outputs, depending on which fields are set.
1569   %%
1570   %% These four are handled here:
1571   %%
1572   %%     articleno, numpages, pages     -> "Article articleno-value, numpages-value pages"
1573   %%     articleno, numpages            -> "Article articleno-value, numpages-value pages"
1574   %%     articleno, pages               -> "Article articleno-value, reduced-pages-value pages"
1575   %%     articleno                      -> "Article articleno-value" and warn about missing numpages
1576   %%
1577   %% The remaining three have already been handled by
1578   %% format.pages.check.without.articleno:
1579   %%
1580   %%     numpages, pages                -> "pages-value"
1581   %%     numpages                       -> "numpages-value"
1582   %%     pages                          -> "pages-value"
1583
1584   articleno empty.or.unknown
1585     {
1586       numpages empty.or.unknown
1587         { }
1588         { "require articleno with numpages field in " cite$ * warning$ }
1589       if$
1590       ""
1591     }
1592     {
1593       numpages empty.or.unknown
1594         {
1595           pages empty.or.unknown
1596             {
1597               "require pages or numpages fields with articleno field in " cite$ * warning$
1598               "" 'page.count :=
1599             }
1600             { reduce.pages.to.page.count }
1601           if$
1602         }
1603         { numpages 'page.count := }
1604       if$
1605
1606       %% The Article number is now handled in format.day.month.year because
1607       %% ACM prefers the style "Digital Libraries 12, 3, Article 5 (July 2008)"
1608       %% over "Digital Libraries 12, 3 (July 2008), Article 5"
1609       %% format.articleno output
1610       format.page.count
1611     }
1612   if$
1613 }
1614
1615 FUNCTION { format.journal.volume.number.day.month.year }
1616 {
1617   % By Young (and Spencer)
1618   % GNP - fixed bugs with missing volume, number, and/or pages
1619   %
1620   % Format journal, volume, number, pages for article types.
1621   %
1622   journal empty.or.unknown
1623     { "no journal in " cite$ * warning$
1624       "" }
1625 %    { journal emphasize.with.italic.correction }
1626      {
1627            journal "Journal of the ACM" =
1628        { "{\it J. ACM}" }
1629        {
1630            journal "American Mathematical Society Translations" =
1631        { "{\it Amer. Math. Soc. Transl.}" }
1632        {
1633            journal "Bulletin of the American Mathematical Society" =
1634        { "{\it Bull. Amer. Math. Soc.}" }
1635        {
1636            journal "Proceedings of the American Mathematical Society" =
1637        { "{\it Proc. Amer. Math. Soc.}" }
1638        {
1639            journal "Transactions of the American Mathematical Society" =
1640        { "{\it Trans. Amer. Math. Soc.}" }
1641        {
1642            journal "Communications of the {ACM}" =
1643        { "{\it Commun. {ACM}}" }
1644        {
1645            journal "{ACM} Computing Surveys" =
1646        { "{\it Comput. Surveys}" }
1647        {
1648            journal "{ACM} Transactions on Mathematical Software" =
1649        { "{\it {ACM} Trans. Math. Software}" }
1650        {
1651            journal "{ACM} {SIGNUM} Newsletter" =
1652        { "{\it {ACM} {SIGNUM} Newslett.}" }
1653        {
1654            journal "American Journal of Sociology" =
1655        { "{\it Amer. J. Sociology}" }
1656        {
1657            journal "Journal of the American Statistical Association" =
1658        { "{\it J. Amer. Statist. Assoc.}" }
1659        {
1660            journal "Applied Mathematics and Computation" =
1661        { "{\it Appl. Math. Comput.}" }
1662        {
1663            journal "American Mathematical Monthly" =
1664        { "{\it Amer. Math. Monthly}" }
1665        {
1666            journal "British Journal of Mathematical and Statistical Psychology" =
1667        { "{\it Brit. J. Math. Statist. Psych.}" }
1668        {
1669            journal "Canadian Mathematical Bulletin" =
1670        { "{\it Canad. Math. Bull.}" }
1671        {
1672            journal "Journal of Computational and Applied Mathematics" =
1673        { "{\it J. Comput. Appl. Math.}" }
1674        {
1675            journal "Journal of Computational Physics" =
1676        { "{\it J. Comput. Phys.}" }
1677        {
1678            journal "Computers and Structures" =
1679        { "{\it Comput. \& Structures}" }
1680        {
1681            journal "The Computer Journal" =
1682        { "{\it Comput. J.}" }
1683        {
1684            journal "Journal of Computer and System Sciences" =
1685        { "{\it J. Comput. System Sci.}" }
1686        {
1687            journal "Contemporary Mathematics" =
1688        { "{\it Contemp. Math.}" }
1689        {
1690            journal "Crelle's Journal" =
1691        { "{\it Crelle's J.}" }
1692        {
1693            journal "Giornale di Mathematiche" =
1694        { "{\it Giorn. Mat.}" }
1695        {
1696            journal "{IEEE} Transactions on Computers" =
1697        { "{\it {IEEE} Trans. Comput.}" }
1698        {
1699            journal "{IEEE} Transactions on Automatic Control" =
1700        { "{\it {IEEE} Trans. Automat. Control}" }
1701        {
1702            journal "Proceedings of the {IEEE}" =
1703        { "{\it Proc. {IEEE}}" }
1704        {
1705            journal "{IEEE} Transactions on Aerospace and Electronic Systems" =
1706        { "{\it {IEEE} Trans. Aerospace Electron. Systems}" }
1707        {
1708            journal "{IMA} Journal of Numerical Analysis" =
1709        { "{\it {IMA} J. Numer. Anal.}" }
1710        {
1711            journal "Information Processing Letters" =
1712        { "{\it Inform. Process. Lett.}" }
1713        {
1714            journal "Journal of the Institute of Mathematics and its Applications" =
1715        { "{\it J. Inst. Math. Appl.}" }
1716        {
1717            journal "International Journal of Control" =
1718        { "{\it Internat. J. Control}" }
1719        {
1720            journal "International Journal for Numerical Methods in Engineering" =
1721        { "{\it Internat. J. Numer. Methods Engrg.}" }
1722        {
1723            journal "International Journal of Supercomputing Applications" =
1724        { "{\it Internat. J. Supercomputing Applic.}" }
1725        {
1726            journal "Journal of Research of the National Bureau of Standards" =
1727        { "{\it J. Res. Nat. Bur. Standards}" }
1728        {
1729            journal "Linear Algebra and its Applications" =
1730        { "{\it Linear Algebra Appl.}" }
1731        {
1732            journal "Journal of Mathematical Analysis and Applications" =
1733        { "{\it J. Math. Anal. Appl.}" }
1734        {
1735            journal "Mathematische Annalen" =
1736        { "{\it Math. Ann.}" }
1737        {
1738            journal "Journal of Mathematical Physics" =
1739        { "{\it J. Math. Phys.}" }
1740        {
1741            journal "Mathematics of Computation" =
1742        { "{\it Math. Comp.}" }
1743        {
1744            journal "Mathematica Scandinavica" =
1745        { "{\it Math. Scand.}" }
1746        {
1747            journal "Mathematical Tables and Other Aids to Computation" =
1748        { "{\it Math. Tables Aids Comput.}" }
1749        {
1750            journal "Numerische Mathematik" =
1751        { "{\it Numer. Math.}" }
1752        {
1753            journal "Pacific Journal of Mathematics" =
1754        { "{\it Pacific J. Math.}" }
1755        {
1756            journal "Journal of Parallel and Distributed Computing" =
1757        { "{\it J. Parallel and Distrib. Comput.}" }
1758        {
1759            journal "Parallel Computing" =
1760        { "{\it Parallel Comput.}" }
1761        {
1762            journal "Philosophical Magazine" =
1763        { "{\it Philos. Mag.}" }
1764        {
1765            journal "Proceedings of the National Academy of Sciences of the USA" =
1766        { "{\it Proc. Nat. Acad. Sci. U. S. A.}" }
1767        {
1768            journal "Quarterly Journal of Mathematics, Oxford, Series (2)" =
1769        { "{\it Quart. J. Math. Oxford Ser. (2)}" }
1770        {
1771            journal "Quarterly of Applied Mathematics" =
1772        { "{\it Quart. Appl. Math.}" }
1773        {
1774            journal "Review of the International Statisical Institute" =
1775        { "{\it Rev. Inst. Internat. Statist.}" }
1776        {
1777            journal "Journal of the Society for Industrial and Applied Mathematics" =
1778        { "{\it J. Soc. Indust. Appl. Math.}" }
1779        {
1780            journal "Journal of the Society for Industrial and Applied Mathematics, Series B, Numerical Analysis" =
1781        { "{\it J. Soc. Indust. Appl. Math. Ser. B Numer. Anal.}" }
1782        {
1783            journal "{SIAM} Journal on Algebraic and Discrete Methods" =
1784        { "{\it {SIAM} J. Algebraic Discrete Methods}" }
1785        {
1786            journal "{SIAM} Journal on Applied Mathematics" =
1787        { "{\it {SIAM} J. Appl. Math.}" }
1788        {
1789            journal "{SIAM} Journal on Computing" =
1790        { "{\it {SIAM} J. Comput.}" }
1791        {
1792            journal "{SIAM} Journal on Matrix Analysis and Applications" =
1793        { "{\it {SIAM} J. Matrix Anal. Appl.}" }
1794        {
1795            journal "{SIAM} Journal on Numerical Analysis" =
1796        { "{\it {SIAM} J. Numer. Anal.}" }
1797        {
1798            journal "{SIAM} Review" =
1799        { "{\it {SIAM} Rev.}" }
1800        {
1801            journal "{SIAM} Journal on Scientific and Statistical Computing" =
1802        { "{\it {SIAM} J. Sci. Statist. Comput.}" }
1803        {
1804            journal "Software Practice and Experience" =
1805        { "{\it Software Prac. Experience}" }
1806        {
1807            journal "Statistical Science" =
1808        { "{\it Statist. Sci.}" }
1809        {
1810            journal "{USSR} Computational Mathematics and Mathematical Physics" =
1811        { "{\it {U. S. S. R.} Comput. Math. and Math. Phys.}" }
1812        {
1813            journal "Journal of {VLSI} and Computer Systems" =
1814        { "{\it J. {VLSI} Comput. Syst.}" }
1815        {
1816            journal "Zeitschrift fur Angewandte Mathematik und Mechanik" =
1817        { "{\it Z. Angew. Math. Mech.}" }
1818        {
1819            journal "Zeitschrift fur Angewandte Mathematik und Physik" =
1820        { "{\it Z. Angew. Math. Phys.}" }
1821        {
1822            journal "ACM Computing Surveys" =
1823        { "{\it Comput. Surveys}" }
1824        {
1825            journal "ACM Transactions on Mathematical Software" =
1826        { "{\it ACM Trans. Math. Software}" }
1827        {
1828            journal "ACM {SIGNUM} Newsletter" =
1829        { "{\it ACM {SIGNUM} Newslett.}" }
1830        {
1831            journal "IEEE Transactions on Computers" =
1832        { "{\it IEEE Trans. Comput.}" }
1833        {
1834            journal "IEEE Transactions on Automatic Control" =
1835        { "{\it IEEE Trans. Automat. Control}" }
1836        {
1837            journal "Proceedings of the IEEE" =
1838        { "{\it Proc. IEEE}" }
1839        {
1840            journal "IEEE Transactions on Aerospace and Electronic Systems" =
1841        { "{\it IEEE Trans. Aerospace Electron. Systems}" }
1842        {
1843            journal "IMA Journal of Numerical Analysis" =
1844        { "{\it IMA J. Numer. Anal.}" }
1845        {
1846            journal "SIAM Journal on Algebraic and Discrete Methods" =
1847        { "{\it SIAM J. Algebraic Discrete Methods}" }
1848        {
1849            journal "SIAM Journal on Applied Mathematics" =
1850        { "{\it SIAM J. Appl. Math.}" }
1851        {
1852            journal "SIAM Journal on Computing" =
1853        { "{\it SIAM J. Comput.}" }
1854        {
1855            journal "SIAM Journal on Matrix Analysis and Applications" =
1856        { "{\it SIAM J. Matrix Anal. Appl.}" }
1857        {
1858            journal "SIAM Journal on Numerical Analysis" =
1859        { "{\it SIAM J. Numer. Anal.}" }
1860        {
1861            journal "SIAM Review" =
1862        { "{\it SIAM Rev.}" }
1863        {
1864            journal "SIAM Journal on Scientific and Statistical Computing" =
1865        { "{\it SIAM J. Sci. Statist. Comput.}" }
1866        {
1867            journal "USSR Computational Mathematics and Mathematical Physics" =
1868        { "{\it U. S. S. R. Comput. Math. and Math. Phys.}" }
1869        {
1870            journal "Journal of VLSI and Computer Systems" =
1871        { "{\it J. VLSI Comput. Syst.}" }
1872        {
1873            journal "Communications of the ACM" =
1874        { "{\it Commun. ACM}" }
1875        %% If no match with cases needing special handling, just output journal name
1876        {  journal emphasize.with.italic.correction  }
1877      if$
1878            }
1879      if$
1880            }
1881      if$
1882            }
1883      if$
1884            }
1885      if$
1886            }
1887      if$
1888            }
1889      if$
1890            }
1891      if$
1892            }
1893      if$
1894            }
1895      if$
1896            }
1897      if$
1898            }
1899      if$
1900            }
1901      if$
1902            }
1903      if$
1904            }
1905      if$
1906            }
1907      if$
1908            }
1909      if$
1910            }
1911      if$
1912            }
1913      if$
1914            }
1915      if$
1916            }
1917      if$
1918            }
1919      if$
1920            }
1921      if$
1922            }
1923      if$
1924            }
1925      if$
1926            }
1927      if$
1928            }
1929      if$
1930            }
1931      if$
1932            }
1933      if$
1934            }
1935      if$
1936            }
1937      if$
1938            }
1939      if$
1940            }
1941      if$
1942            }
1943      if$
1944            }
1945      if$
1946            }
1947      if$
1948            }
1949      if$
1950            }
1951      if$
1952            }
1953      if$
1954            }
1955      if$
1956            }
1957      if$
1958            }
1959      if$
1960            }
1961      if$
1962            }
1963      if$
1964            }
1965      if$
1966            }
1967      if$
1968            }
1969      if$
1970            }
1971      if$
1972            }
1973      if$
1974            }
1975      if$
1976            }
1977      if$
1978            }
1979      if$
1980            }
1981      if$
1982            }
1983      if$
1984            }
1985      if$
1986            }
1987      if$
1988            }
1989      if$
1990            }
1991      if$
1992            }
1993      if$
1994            }
1995      if$
1996            }
1997      if$
1998            }
1999      if$
2000            }
2001      if$
2002            }
2003      if$
2004            }
2005      if$
2006            }
2007      if$
2008            }
2009      if$
2010            }
2011      if$
2012            }
2013      if$
2014            }
2015      if$
2016            }
2017      if$
2018            }
2019      if$
2020            }
2021      if$
2022            }
2023      if$
2024            }
2025      if$
2026            }
2027      if$
2028            }
2029      if$
2030            }
2031      if$
2032            }
2033      if$
2034            }
2035      if$
2036            }
2037      if$
2038            }
2039      if$
2040            }
2041      if$
2042          }
2043     if$
2044
2045   number empty.or.unknown
2046     {
2047       volume empty.or.unknown
2048         { "no number and no volume in " cite$ * warning$ "" * }
2049         { " " * " {" * volume * "}" * }
2050       if$
2051     }
2052     {
2053       volume empty.or.unknown
2054         {
2055           "unusual to have number, but no volume, for " cite$ * warning$
2056           " " * number *
2057         }
2058         { " " * volume comma " " * number * * }
2059       if$
2060     }
2061   if$
2062
2063   format.day.month.year *
2064 }
2065
2066 FUNCTION { format.chapter.pages }
2067 {
2068   chapter empty.or.unknown
2069     'format.pages
2070     { type empty.or.unknown
2071         { "Chapter" } % gnp - changed to mixed case
2072         { type "t" change.case$ }
2073       if$
2074       chapter tie.or.space.connect
2075       pages empty.or.unknown
2076         {"page numbers missing in " cite$ * warning$} % gnp - added check
2077         { ", " * format.pages * }
2078       if$
2079     }
2080   if$
2081 }
2082
2083 FUNCTION { format.in.emphasize.booktitle }
2084 { % jtb: format for collections or proceedings not appearing in a journal
2085   booktitle empty.or.unknown
2086   { "" }
2087   { "In " format.emphasize.booktitle * }
2088   if$
2089 }
2090
2091 FUNCTION { format.in.booktitle }
2092 { % jtb: format for proceedings appearing in a journal
2093   booktitle empty.or.unknown
2094   { "" }
2095   { "In " booktitle * }
2096   if$
2097 }
2098
2099 FUNCTION { format.in.ed.booktitle }
2100 {
2101   booktitle empty.or.unknown
2102   { "" }
2103   { editor empty.or.unknown
2104     { "In " format.emphasize.booktitle * }
2105                 % jtb: swapped editor location
2106     { "In " format.emphasize.booktitle * ", " * format.editors.fml * }
2107     if$
2108   }
2109   if$
2110 }
2111
2112 FUNCTION { format.thesis.type }
2113 { % call with default type on stack top
2114   type empty.or.unknown
2115     'skip$    % use default type
2116     {
2117       pop$    % discard default type
2118       % NO: it is silly to have to brace protect every degree type!:  type "t" change.case$
2119       type
2120     }
2121   if$
2122 }
2123
2124 FUNCTION { format.tr.number }
2125 {
2126   type empty.or.unknown
2127 %    { "Tech. Rep." }     
2128     { "{T}echnical {R}eport" }     % ACM wants it explicit (Gerry 9/28)
2129     'type
2130   if$
2131   number empty.or.unknown
2132     { "t" change.case$ }
2133     %% LOOKS BAD: { "." * number tie.or.space.connect }
2134     %% Prefer "Research report RJ687." to "Research report. RJ687."
2135     { number tie.or.space.connect }
2136   if$
2137 }
2138
2139 FUNCTION { format.advisor }
2140 {
2141   advisor empty.or.unknown
2142     { "" }
2143     { "Advisor(s) " advisor * }
2144   if$
2145 }
2146
2147 FUNCTION { format.article.crossref }
2148 { "See"
2149   "\citeN{" * crossref * "}" *
2150 }
2151
2152 FUNCTION { format.crossref.editor }
2153 {
2154   editor #1 "{vv~}{ll}" format.name$
2155   editor num.names$ duplicate$
2156   #2 >
2157     { pop$ " et~al\mbox{.}" * }         % jrh: avoid spacing problems
2158     { #2 <
2159     'skip$
2160     { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
2161         { " et~al\mbox{.}" * }          % jrh: avoid spacing problems
2162         { " and " * editor #2 "{vv~}{ll}" format.name$ * }
2163       if$
2164     }
2165       if$
2166     }
2167   if$
2168 }
2169
2170 FUNCTION { format.book.crossref }
2171 {
2172   volume empty.or.unknown
2173     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
2174       "In "
2175     }
2176     { "Volume" volume tie.or.space.connect % gnp - changed to mixed case
2177       " of " *
2178     }
2179   if$
2180   editor empty.or.unknown
2181   editor field.or.null author field.or.null =
2182   or
2183     { key empty.or.unknown
2184     { series empty.or.unknown
2185         { "need editor, key, or series for " cite$ * " to crossref " *
2186           crossref * warning$
2187           "" *
2188         }
2189         { "{\em " * series * "\/}" * }
2190       if$
2191     }
2192     { key * }
2193       if$
2194     }
2195     { format.crossref.editor * }
2196   if$
2197   " \citeN{" * crossref * "}" *
2198 }
2199
2200 FUNCTION { format.incoll.inproc.crossref }
2201 { "See"
2202   " \citeN{" * crossref * "}" *
2203 }
2204
2205 FUNCTION { format.lab.names }
2206 {
2207   % format.lab.names:
2208   %
2209   % determines "short" names for the abbreviated author information.
2210   % "Long" labels are created in calc.label, using the routine my.full.label
2211   % to format author and editor fields.
2212   %
2213   % There are 4 cases for labels.   (n=3 in the example)
2214   % a) one author             Foo
2215   % b) one to n               Foo, Bar and Baz
2216   % c) use of "and others"    Foo, Bar et al.
2217   % d) more than n            Foo et al.
2218
2219   's :=
2220   s num.names$ 'numnames :=
2221   numnames #2 >    % change number to number of others allowed before
2222                    % forcing "et al".
2223     { s #1 "{vv~}{ll}" format.name$ " et~al\mbox{.}" * } % jrh: \mbox{} added
2224     {
2225       numnames #1 - 'namesleft :=
2226       #2 'nameptr :=
2227       s #1 "{vv~}{ll}" format.name$
2228         { namesleft #0 > }
2229         { nameptr numnames =
2230             { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" =
2231                 { " et~al\mbox{.}" * }          % jrh: avoid spacing problems
2232                 { " and " * s nameptr "{vv~}{ll}" format.name$ * }
2233               if$
2234             }
2235             { ", " * s nameptr "{vv~}{ll}" format.name$ * }
2236           if$
2237           nameptr #1 + 'nameptr :=
2238           namesleft #1 - 'namesleft :=
2239         }
2240       while$
2241     }
2242   if$
2243 }
2244
2245 FUNCTION { author.key.label }
2246 {
2247   author empty.or.unknown
2248     { key empty.or.unknown
2249           { "no key, author in " cite$ * warning$
2250             cite$ #1 #3 substring$ }
2251          'key
2252       if$
2253     }
2254     { author format.lab.names }
2255   if$
2256 }
2257
2258 FUNCTION { author.key.organization.label }
2259 { % added - gnp. Provide label formatting by organization if author is null.
2260   author empty.or.unknown
2261     { organization empty.or.unknown
2262         { key empty.or.unknown
2263             { "no key, author or organization in " cite$ * warning$
2264               cite$ #1 #3 substring$ }
2265             'key
2266           if$
2267         }
2268         { organization }
2269       if$
2270     }
2271     { author format.lab.names }
2272   if$
2273 }
2274
2275 FUNCTION { editor.key.organization.label }
2276 { % added - gnp. Provide label formatting by organization if editor is null.
2277   editor empty.or.unknown
2278     { organization empty.or.unknown
2279         { key empty.or.unknown
2280             { "no key, editor or organization in " cite$ * warning$
2281               cite$ #1 #3 substring$ }
2282             'key
2283           if$
2284         }
2285         { organization }
2286       if$
2287     }
2288     { editor format.lab.names }
2289   if$
2290 }
2291
2292 FUNCTION { author.editor.key.label }
2293 {
2294   author empty.or.unknown
2295     { editor empty.or.unknown
2296           { key empty.or.unknown
2297                { "no key, author, or editor in " cite$ * warning$
2298                  cite$ #1 #3 substring$ }
2299              'key
2300            if$
2301          }
2302           { editor format.lab.names }
2303       if$
2304     }
2305     { author format.lab.names }
2306   if$
2307 }
2308
2309 FUNCTION { calc.label }
2310 {
2311   % Changed - GNP. See also author.organization.sort, editor.organization.sort
2312   % Form label for BibTeX entry. The classification of which fields are used
2313   % for which type of entry (book, inbook, etc.) are taken from alpha.bst.
2314   % The change here from newapa is to also include organization as a
2315   % citation label if author or editor is missing.
2316
2317   type$ "book" =
2318   type$ "inbook" =
2319   or
2320   type$ "periodical" =
2321   or
2322     'author.editor.key.label
2323     { type$ "proceedings" =
2324         'editor.key.organization.label
2325         { type$ "manual" =
2326             'author.key.organization.label
2327             'author.key.label
2328           if$
2329         }
2330       if$
2331     }
2332   if$
2333
2334   author empty.or.unknown  % generate the full label citation information.
2335     {
2336       editor empty.or.unknown
2337         {
2338           organization empty.or.unknown
2339             {
2340               key empty.or.unknown
2341                 {
2342                   "no author, editor, organization, or key in " cite$ * warning$
2343                   "??"
2344                 }
2345                 { key }
2346               if$
2347             }
2348             { organization }
2349           if$
2350         }
2351         { editor my.full.label }
2352       if$
2353     }
2354     { author my.full.label }
2355   if$
2356
2357   % leave label on the stack, to be popped when required.
2358
2359   "}{" * swap$ * "}{" *
2360   %  year field.or.null purify$ #-1 #4 substring$ *
2361   %
2362   % save the year for sort processing afterwards (adding a, b, c, etc.)
2363   %
2364   year field.or.null purify$ #-1 #4 substring$
2365   'label.year :=
2366 }
2367
2368 %
2369 % Change by Gerry: use number-like citations for transactions
2370 % 2011/03/23
2371 % Reverting: Ayman
2372 FUNCTION {output.bibitem}
2373 { newline$
2374   "\bibitem{" write$
2375   cite$ write$
2376   "}" write$
2377   newline$
2378   ""
2379   before.all 'output.state :=
2380 }
2381
2382 % FUNCTION { output.bibitem }
2383 % {
2384 %   newline$
2385 %   "\bibitem[\protect\citeauthoryear{" write$
2386 %   calc.label write$
2387 %   sort.year write$
2388 %   "}]%" writeln
2389 %   "        {" write$
2390 %   cite$ write$
2391 %   "}" writeln
2392 %   ""
2393 %   before.all 'output.state :=
2394 % }
2395
2396
2397 FUNCTION { output.issue.doi.coden.isxn.lccn.url }
2398 { % enter and return with stack empty
2399   %% We switch now from buffered output to output of complete lines, so
2400   %% that the Issue .. URL data have their own lines, and are less likely
2401   %% to be line-wrapped by BibTeX's short-sighted algorithm, which wraps
2402   %% lines longer than 79 characters, backtracking to what it thinks is
2403   %% a break point in the string.  Any such wrapping MUST be undone to
2404   %% prevent percent-newline from appearing in DOIs and URLs.  The
2405   %% output data are intentionally wrapped in \showxxx{} macros at
2406   %% beginning of line, and that supply their own punctuation (if they
2407   %% are not defined to suppress output entirely), to make it easier for
2408   %% other software to recover them from .bbl files.
2409   %%
2410   %% It also makes it possible to later change the macro definitions
2411   %% to suppress particular output values, or alter their appearance.
2412   %%
2413   %% Note that it is possible for theses, technical reports, and
2414   %% manuals to have ISBNs, and anything that has an ISBN may also
2415   %% have an ISSN.  When there are no values for these keys, there
2416   %% is no output generated for them here.
2417
2418   "\newblock" writeln
2419   after.block 'output.state :=
2420
2421   output.issue
2422   output.isbn
2423   output.coden  % CODEN is functionally like ISSN, so output them sequentially
2424   output.issn
2425   output.lccn
2426   output.doi    % DOI is ALWAYS last according to CrossRef DOI documentation
2427   output.url    % but ACM wants URL last
2428 }
2429
2430 FUNCTION { output.issue.doi.coden.isxn.lccn.url.note }
2431 { % enter with stack empty, return with empty string on stack
2432   output.issue.doi.coden.isxn.lccn.url
2433   note empty.or.unknown
2434     { }
2435     {
2436       "\newblock" writeln
2437       output.note
2438     }
2439   if$
2440   ""
2441 }
2442
2443 FUNCTION { output.issue.doi.coden.isxn.lccn.url.note.check }
2444 { % enter with stack empty, return with empty string on stack
2445   output.issue.doi.coden.isxn.lccn.url
2446   note empty.or.unknown
2447     { }
2448     {
2449       "\newblock" writeln
2450       output.note.check
2451     }
2452   if$
2453   ""
2454 }
2455
2456 FUNCTION { article }
2457 {
2458   output.bibitem
2459
2460   author empty.or.unknown
2461     {
2462       editor empty.or.unknown
2463         { "neither author and editor supplied for " cite$ * warning$ }
2464         { format.editors "editor" output.check }
2465       if$
2466     }
2467     { format.authors "author" output.check }
2468   if$
2469
2470   author format.no.key output       % added
2471   output.year.check                 % added
2472   new.block
2473   format.articletitle "title" output.check
2474   new.block
2475   howpublished output
2476
2477   crossref missing$
2478     { format.journal.volume.number.day.month.year }
2479     {
2480       "cross reference in @Article{...} is unusual" warning$
2481       format.article.crossref output.nonnull
2482     }
2483   if$
2484   output
2485
2486   format.pages.check.without.articleno output
2487   format.articleno.numpages output
2488   fin.block
2489   output.issue.doi.coden.isxn.lccn.url.note
2490   fin.entry
2491 }
2492
2493 FUNCTION { book }
2494 {
2495   output.bibitem
2496   author empty.or.unknown
2497     { format.editors "author and editor" output.check }
2498     { format.authors output.nonnull
2499       crossref missing$
2500         { "author and editor" editor either.or.check }
2501         'skip$
2502       if$
2503     }
2504   if$
2505   output.year.check       % added
2506   new.block
2507   format.btitle "title" output.check
2508   crossref missing$
2509     { new.sentence              % jtb: start a new sentence for series/volume
2510       format.bvolume output
2511       new.block
2512       format.number.series output
2513       new.sentence
2514       publisher "publisher" output.check
2515       address "address" output.check    % jtb: require address
2516       fin.sentence
2517       pages empty.or.unknown
2518         { format.bookpages }    % use bookpages when pages empty
2519         { format.pages.check "pages" tie.or.space.connect }
2520       if$
2521       output
2522     }
2523     { new.block
2524       format.book.crossref output.nonnull
2525     }
2526   if$
2527   fin.block
2528   output.issue.doi.coden.isxn.lccn.url.note
2529   fin.entry
2530 }
2531
2532 FUNCTION { booklet }
2533 {
2534   output.bibitem
2535   format.authors output
2536   author format.key output          % added
2537   output.year.check                 % added
2538   new.block
2539   format.title "title" output.check
2540   new.block
2541   howpublished output
2542   address output
2543   fin.block
2544   output.issue.doi.coden.isxn.lccn.url.note
2545   fin.entry
2546 }
2547
2548 FUNCTION { inbook }
2549 {
2550   output.bibitem
2551   author empty.or.unknown
2552     { format.editors
2553       "author and editor" output.check
2554     }
2555     { format.authors output.nonnull
2556       crossref missing$
2557     { "author and editor" editor either.or.check }
2558     'skip$
2559       if$
2560     }
2561   if$
2562   output.year.check                 % added
2563   new.block
2564   format.btitle "title" output.check
2565   crossref missing$
2566     { new.sentence              % jtb: start a new sentence for series/volume
2567       format.bvolume output
2568       new.block
2569       format.number.series output
2570       new.sentence
2571       publisher "publisher" output.check
2572       address "address" output.check    % jtb: require address
2573       format.bookpages output
2574       format.chapter.pages
2575       "chapter and pages" output.check  % jtb: moved from before publisher
2576     }
2577     {
2578       format.bookpages output
2579       format.chapter.pages "chapter and pages" output.check
2580       new.block
2581       format.book.crossref output.nonnull
2582     }
2583   if$
2584   fin.block
2585   output.issue.doi.coden.isxn.lccn.url.note
2586   fin.entry
2587 }
2588
2589 FUNCTION { incollection }
2590 {
2591   output.bibitem
2592   format.authors "author" output.check
2593   author format.key output       % added
2594   output.year.check              % added
2595   new.block
2596   format.articletitle "title" output.check
2597   new.block
2598   crossref missing$
2599     { format.in.ed.booktitle "booktitle" output.check
2600       new.sentence                % jtb: start a new sentence for series/volume
2601       format.bvolume output
2602       format.number.series output
2603       new.sentence
2604       publisher "publisher" output.check
2605       address "address" output.check      % jtb: require address
2606       format.bookpages output
2607       format.chapter.pages output % gnp - was special.output.nonnull
2608                                   % left out comma before page numbers
2609                                   % jtb: moved from before publisher
2610     }
2611     {
2612       format.incoll.inproc.crossref output.nonnull
2613       format.chapter.pages output
2614     }
2615   if$
2616   fin.block
2617   output.issue.doi.coden.isxn.lccn.url.note
2618   fin.entry
2619 }
2620
2621 FUNCTION { inproceedings }
2622 {
2623   output.bibitem
2624   format.authors "author" output.check
2625   author format.key output            % added
2626   output.year.check                   % added
2627   new.block
2628   format.articletitle "title" output.check
2629   howpublished output.dot.space
2630   crossref missing$
2631     {
2632       journal missing$          % jtb: proceedings appearing in journals
2633         { format.in.emphasize.booktitle format.city "booktitle"  output.check.dot.space
2634           format.series output.removenospace
2635           format.editors.fml output % BV 2011/09/27 Moved dot to comma
2636           format.bvolume.noseries output
2637           new.sentence
2638           organization output
2639           publisher "publisher" output.check % jtb: require publisher (?)
2640           address "address" output.check  % jtb: require address
2641           format.bookpages output
2642         }
2643         {
2644            format.in.booktitle format.city "booktitle" output.check
2645            format.editors.fml output
2646            new.sentence
2647            format.journal.volume.number.day.month.year output
2648         }
2649       if$
2650       format.articleno output
2651       format.pages.check.without.articleno output
2652     }
2653     {
2654       format.incoll.inproc.crossref output.nonnull
2655       format.articleno output
2656       format.pages.check.without.articleno output
2657     }
2658   if$
2659   format.articleno.numpages output
2660   fin.block
2661   output.issue.doi.coden.isxn.lccn.url.note
2662   fin.entry
2663 }
2664
2665 FUNCTION { conference } { inproceedings }
2666
2667 FUNCTION { manual }
2668 {
2669   output.bibitem
2670   author empty.or.unknown
2671     { editor empty.or.unknown
2672       { organization "organization" output.check
2673         organization format.key output }  % if all else fails, use key
2674       { format.editors "author and editor" output.check }
2675       if$
2676     }
2677     { format.authors output.nonnull }
2678     if$
2679   output.year.check                 % added
2680   new.block
2681   format.btitle "title" output.check
2682   organization address new.block.checkb
2683   % jtb: back to normal style: organization, address
2684   organization "organization" output.check
2685   address output
2686   fin.block
2687   output.issue.doi.coden.isxn.lccn.url.note
2688   fin.entry
2689 }
2690
2691 FUNCTION { mastersthesis }
2692 {
2693   output.bibitem
2694   format.authors "author" output.check
2695   author format.key output          % added
2696   output.year.check                 % added
2697   new.block
2698   format.title emphasize "title" output.check  % NB: ACM style requires emphasized thesis title
2699   new.block
2700   "Master's\ thesis" format.thesis.type output new.sentence  % Added dot. BV 2011/09/27
2701   school "school" output.check
2702   address output
2703   new.block
2704   format.advisor output
2705   fin.block
2706   output.issue.doi.coden.isxn.lccn.url.note
2707   fin.entry
2708 }
2709
2710 FUNCTION { misc }
2711 {
2712   output.bibitem
2713   format.authors output
2714   author format.key output            % added
2715   output.year.check                   % added
2716   title howpublished new.block.checkb
2717   format.title output
2718   new.block
2719   howpublished output
2720   "" output.nonnull.dot.space
2721   output.day.month.year              % Gerry - appears odd if (only) the year is 'repeated' but (appears) 'valuable' if the month/day is _also_ included - 2011/09/28
2722   fin.block
2723   output.issue.doi.coden.isxn.lccn.url.note
2724   fin.entry
2725 }
2726
2727 FUNCTION { phdthesis }
2728 {
2729   output.bibitem
2730   format.authors "author" output.check
2731   author format.key output          % added
2732   output.year.check                 % added
2733   new.block
2734   format.title emphasize "title" output.check  % NB: ACM style requires emphasized thesis title
2735   new.block
2736  "Ph.D. Dissertation" format.thesis.type output new.sentence % Added dot. BV 2011/09/27
2737   school "school" output.check
2738   address output
2739   new.block
2740   format.advisor output
2741   fin.block
2742   output.issue.doi.coden.isxn.lccn.url.note
2743   fin.entry
2744 }
2745
2746 FUNCTION {format.date}
2747 { year empty.or.unknown
2748     { month empty.or.unknown
2749         {
2750           ""                    % output empty date if year/month both empty
2751           day empty.or.unknown
2752             {  }
2753             { "there's a day but no month or year in " cite$ * warning$ }
2754           if$
2755         }
2756         { "there's a month but no year in " cite$ * warning$
2757           month
2758           day empty.or.unknown
2759             { }
2760             { " " * day * }
2761           if$
2762         }
2763       if$
2764     }
2765     { month empty.or.unknown
2766         {
2767           year                  % output only year if month empty
2768           day empty.or.unknown
2769             {  }
2770             { "there's a day and year but no month in " cite$ * warning$ }
2771           if$
2772         }
2773         {
2774           month " " *
2775           day empty.or.unknown
2776             { }
2777             { day * ", " * }
2778           if$
2779           year *
2780         }
2781       if$
2782     }
2783   if$
2784 }
2785
2786 FUNCTION {new.block.checka}
2787 {
2788   empty.or.unknown
2789     'skip$
2790     'new.block
2791   if$
2792 }
2793
2794 FUNCTION { periodical }
2795 {
2796   output.bibitem
2797   editor empty.or.unknown
2798     { organization output }
2799     { format.editors output.nonnull }
2800   if$
2801   new.block
2802   title emphasize "title" output.check
2803   format.date output
2804   new.sentence
2805   publisher output
2806   address output
2807   howpublished new.block.checka
2808   howpublished output
2809   fin.block
2810   output.issue.doi.coden.isxn.lccn.url.note
2811   fin.entry
2812 }
2813
2814 FUNCTION { proceedings }
2815 {
2816   output.bibitem
2817   editor empty.or.unknown
2818     { organization output
2819       organization format.key output }  % gnp - changed from author format.key
2820     { format.editors output.nonnull }
2821   if$
2822   % author format.key output             % gnp - removed (should be either
2823   %                                        editor or organization
2824   output.year.check                    % added (newapa)
2825   new.block
2826   format.btitle format.city "title" output.check        % jtb: added city
2827   new.sentence
2828   format.bvolume output
2829   format.number.series output
2830   new.sentence
2831   organization output
2832   % jtb: normal order: publisher, address
2833   publisher output
2834   address output
2835   fin.block
2836   output.issue.doi.coden.isxn.lccn.url.note
2837   fin.entry
2838 }
2839
2840 FUNCTION { techreport }
2841 {
2842   output.bibitem
2843   format.authors "author" output.check
2844   author format.key output             % added
2845   output.year.check                    % added
2846   new.block
2847   format.btitle "title" output.check
2848   new.block
2849 %   format.tr.number output               % jtb: moved month ...
2850   format.tr.number output new.sentence    % Gerry  - need dot 2011/09/28
2851   institution "institution" output.check
2852   address output
2853   new.sentence
2854   format.named.pages output
2855   % ACM omits year at end in transactions style
2856   % format.day.month.year output.nonnull.dot.space  % jtb: ... to here (no parens)
2857   fin.block
2858   output.issue.doi.coden.isxn.lccn.url.note
2859   fin.entry
2860 }
2861
2862 FUNCTION { unpublished }
2863 {
2864   output.bibitem
2865   format.authors
2866   "author" output.check
2867   author format.key output              % added
2868   output.year.check                     % added
2869   new.block
2870   format.title "title" output.check
2871   fin.sentence
2872   output.day.month.year                 % UTAH
2873   fin.block
2874   output.issue.doi.coden.isxn.lccn.url.note.check
2875   fin.entry
2876 }
2877
2878 FUNCTION { default.type } { misc }
2879
2880 %%% ACM journal-style month definitions: full name if 1--5 letters, else
2881 %%% abbreviation of 3 or 4 characters and a dot
2882
2883 MACRO {jan}             {"Jan."}
2884
2885 MACRO {feb}             {"Feb."}
2886
2887 MACRO {mar}             {"March"}
2888
2889 MACRO {apr}             {"April"}
2890
2891 MACRO {may}             {"May"}
2892
2893 MACRO {jun}             {"June"}
2894
2895 MACRO {jul}             {"July"}
2896
2897 MACRO {aug}             {"Aug."}
2898
2899 MACRO {sep}             {"Sept."}
2900
2901 MACRO {oct}             {"Oct."}
2902
2903 MACRO {nov}             {"Nov."}
2904
2905 MACRO {dec}             {"Dec."}
2906
2907
2908 %%% ====================================================================
2909 %%%                 I M P O R T A N T   C H A N G E
2910 %%%
2911 %%% For the 2009 release of the official acm-*.bst files, there are to
2912 %%% be NO predefined journal abbreviations in those style files.
2913 %%%
2914 %%% ACM may later develop an official list of mappings of full journal
2915 %%% names of commonly-cited journals to ACM-preferred abbreviations, but
2916 %%% authors should consider that use of any of these commented-out
2917 %%% abbreviations is DEPRECATED unless the BibTeX file itself provides
2918 %%% its own @String{name = "value"} definitions.
2919 %%%
2920 %%% Use of journal (and publisher and address) @String{...}
2921 %%% abbreviations, as opposed to explicit value assignments such as
2922 %%% journal = "J. ACM" and publisher = "IEEE", is preferred in
2923 %%% bibliographic databases, because it makes it easier for journal
2924 %%% production staff to replace those definitions by publisher-preferred
2925 %%% abbreviations when articles are typeset for publication.
2926 %%%
2927 %%% For historical reasons, and because some of these abbreviations are
2928 %%% used in other (non-ACM) bibliography style files, they are preserved
2929 %%% here in comments.  Future releases of the acm*-.bst files are likely
2930 %%% to remove them entirely.
2931 %%% ====================================================================
2932 %%%
2933 %%% DEPRECATED: MACRO {acmcs}           {"ACM Comput. Surv."}                   % original BibTeX
2934 %%% DEPRECATED:
2935 %%% DEPRECATED: MACRO {acmlett}         {"ACM Lett. Program. Lang. Syst."}
2936 %%% DEPRECATED:
2937 %%% DEPRECATED: MACRO {acta}            {"Acta Inf."}                           % original BibTeX
2938 %%% DEPRECATED:
2939 %%% DEPRECATED: MACRO {ai}              {"Artificial Intelligence"}
2940 %%% DEPRECATED:
2941 %%% DEPRECATED: MACRO {al}              {"Ada Lett."}
2942 %%% DEPRECATED:
2943 %%% DEPRECATED: MACRO {acr}             {"Adv. Comput. Res."}
2944 %%% DEPRECATED:
2945 %%% DEPRECATED: MACRO {bit}             {"Bit"}
2946 %%% DEPRECATED:
2947 %%% DEPRECATED: MACRO {cacm}            {"Commun. ACM"}                         % original BibTeX
2948 %%% DEPRECATED:
2949 %%% DEPRECATED: MACRO {cj}              {"Comput. J."}
2950 %%% DEPRECATED:
2951 %%% DEPRECATED: MACRO {cn}              {"Comput. Netw."}
2952 %%% DEPRECATED:
2953 %%% DEPRECATED: MACRO {cl}              {"Comput. Lang."}
2954 %%% DEPRECATED:
2955 %%% DEPRECATED: MACRO {ibmjrd}          {"IBM J. Res. and Development"}         % original BibTeX
2956 %%% DEPRECATED:
2957 %%% DEPRECATED: MACRO {ibmsj}           {"IBM Systems Journal"}                 % original BibTeX
2958 %%% DEPRECATED:
2959 %%% DEPRECATED: MACRO {ict}             {"Inf. Contr."}
2960 %%% DEPRECATED:
2961 %%% DEPRECATED: MACRO {ieebcs}          {"IEE/BCS Softw. Eng. J."}
2962 %%% DEPRECATED:
2963 %%% DEPRECATED: MACRO {ieees}           {"IEEE Softw."}
2964 %%% DEPRECATED:
2965 %%% DEPRECATED: MACRO {ieeese}          {"IEEE Trans. Softw. Eng."}             % original BibTeX
2966 %%% DEPRECATED:
2967 %%% DEPRECATED: MACRO {ieeetc}          {"IEEE Trans. Comput."}                 % original BibTeX
2968 %%% DEPRECATED:
2969 %%% DEPRECATED: MACRO {ieeetcad}        {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"} % original BibTeX
2970 %%% DEPRECATED:
2971 %%% DEPRECATED: MACRO {ieeetpds}        {"IEEE Trans. Parall. Distrib. Syst."}
2972 %%% DEPRECATED:
2973 %%% DEPRECATED: MACRO {ieeetit}         {"IEEE Trans. Inf. Theory"}
2974 %%% DEPRECATED:
2975 %%% DEPRECATED: MACRO {ipl}             {"Inf. Process. Lett."}                 % original BibTeX
2976 %%% DEPRECATED:
2977 %%% DEPRECATED: MACRO {icp}             {"Inf. Comput."}
2978 %%% DEPRECATED:
2979 %%% DEPRECATED: MACRO {ist}             {"Inf. Softw. Tech."}
2980 %%% DEPRECATED:
2981 %%% DEPRECATED: MACRO {ijsa}            {"Int. J. Supercomput. Appl."}
2982 %%% DEPRECATED:
2983 %%% DEPRECATED: MACRO {ijpp}            {"Int. J. Parallel Program."}
2984 %%% DEPRECATED:
2985 %%% DEPRECATED: MACRO {jacm}            {"J. ACM"}                              % original BibTeX
2986 %%% DEPRECATED:
2987 %%% DEPRECATED: % MACRO {jcss}          {"Journal of Computer and System Sciences"} % original BibTeX
2988 %%% DEPRECATED: MACRO {jcss}            {"J. Comput. Syst. Sci."}               % original BibTeX
2989 %%% DEPRECATED:
2990 %%% DEPRECATED: MACRO {jlp}             {"J. Logic Program."}
2991 %%% DEPRECATED:
2992 %%% DEPRECATED: MACRO {jfp}             {"J. Funct. Program."}
2993 %%% DEPRECATED:
2994 %%% DEPRECATED: MACRO {jsmrp}           {"J. Softw. Maint. Res. Pract."}
2995 %%% DEPRECATED:
2996 %%% DEPRECATED: MACRO {jss}             {"J. Syst. Softw."}
2997 %%% DEPRECATED:
2998 %%% DEPRECATED: MACRO {jlc}             {"J. Logic and Comput."}
2999 %%% DEPRECATED:
3000 %%% DEPRECATED: MACRO {jlsc}            {"J. Lisp Symb. Comput."}
3001 %%% DEPRECATED:
3002 %%% DEPRECATED: MACRO {lpls}            {"Lett. Program. Lang. Syst."}
3003 %%% DEPRECATED:
3004 %%% DEPRECATED: MACRO {mor}             {"Math. Oper. Res."}
3005 %%% DEPRECATED:
3006 %%% DEPRECATED: MACRO {mscs}            {"Math. Struct. Comput. Sci."}
3007 %%% DEPRECATED:
3008 %%% DEPRECATED: MACRO {mst}             {"Math. Syst. Theor."}
3009 %%% DEPRECATED:
3010 %%% DEPRECATED: MACRO {ngc}             {"New Gen. Comput."}
3011 %%% DEPRECATED:
3012 %%% DEPRECATED: MACRO {scp}             {"Sci. Comput. Program."}               % original BibTeX
3013 %%% DEPRECATED:
3014 %%% DEPRECATED: MACRO {sicomp}          {"SIAM J. Comput."}                     % original BibTeX
3015 %%% DEPRECATED:
3016 %%% DEPRECATED: MACRO {spe}             {"Softw. Pract. Exper."}
3017 %%% DEPRECATED:
3018 %%% DEPRECATED: MACRO {tocs}            {"ACM Trans. Comput. Syst."}            % original BibTeX
3019 %%% DEPRECATED:
3020 %%% DEPRECATED: MACRO {tods}            {"ACM Trans. Database Syst."}           % original BibTeX
3021 %%% DEPRECATED:
3022 %%% DEPRECATED: MACRO {tog}             {"ACM Trans. Graphics"}                 % original BibTeX
3023 %%% DEPRECATED:
3024 %%% DEPRECATED: MACRO {toms}            {"ACM Trans. Math. Softw."}             % original BibTeX
3025 %%% DEPRECATED:
3026 %%% DEPRECATED: MACRO {toois}           {"ACM Trans. Office Inf. Syst."}        % original BibTeX
3027 %%% DEPRECATED:
3028 %%% DEPRECATED: MACRO {toplas}          {"ACM Trans. Program. Lang. Syst."}     % original BibTeX
3029 %%% DEPRECATED:
3030 %%% DEPRECATED: MACRO {tcs}             {"Theor. Comput. Sci."}                 % original BibTeX
3031 %%% DEPRECATED:
3032 %%% DEPRECATED: MACRO {tr}              {"Tech. Rep."}
3033 %%% ====================================================================
3034
3035 READ
3036
3037 FUNCTION { sortify }
3038 {
3039   purify$
3040   "l" change.case$
3041 }
3042
3043 FUNCTION { chop.word }
3044 {
3045   's :=
3046   'len :=
3047   s #1 len substring$ =
3048     { s len #1 + global.max$ substring$ }
3049     's
3050   if$
3051 }
3052
3053 FUNCTION { sort.format.names }
3054 {
3055   's :=
3056   #1 'nameptr :=
3057   ""
3058   s num.names$ 'numnames :=
3059   numnames 'namesleft :=
3060     { namesleft #0 > }
3061     { nameptr #1 >
3062           { "   " * }
3063          'skip$
3064       if$
3065   %      s nameptr "{ff{ } }{ll{ }}{  vv{ }}{  jj{ }}" format.name$ 't :=
3066       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't :=
3067       nameptr numnames = t "others" = and
3068           { " et~al" * }
3069           { t sortify * }
3070       if$
3071       nameptr #1 + 'nameptr :=
3072       namesleft #1 - 'namesleft :=
3073     }
3074   while$
3075 }
3076
3077 FUNCTION { sort.format.title }
3078 {
3079   't :=
3080   "A " #2
3081     "An " #3
3082       "The " #4 t chop.word
3083     chop.word
3084   chop.word
3085   sortify
3086   #1 global.max$ substring$
3087 }
3088
3089 FUNCTION { author.sort }
3090 {
3091   author empty.or.unknown
3092     { key empty.or.unknown
3093          { "to sort, need author or key in " cite$ * warning$
3094            "" }
3095          { key sortify }
3096       if$
3097     }
3098     { author sort.format.names }
3099   if$
3100 }
3101
3102 FUNCTION { author.editor.sort }
3103 {
3104   author empty.or.unknown
3105     {
3106       editor empty.or.unknown
3107          {
3108            key empty.or.unknown
3109              { "to sort, need author, editor, or key in " cite$ * warning$
3110                ""
3111              }
3112              { key sortify }
3113            if$
3114          }
3115          { editor sort.format.names }
3116       if$
3117     }
3118     { author sort.format.names }
3119   if$
3120 }
3121
3122 FUNCTION { author.organization.sort }
3123 {
3124   % added - GNP. Stack author or organization for sorting (from alpha.bst).
3125   % Unlike alpha.bst, we need entire names, not abbreviations
3126
3127   author empty.or.unknown
3128     { organization empty.or.unknown
3129         { key empty.or.unknown
3130             { "to sort, need author, organization, or key in " cite$ * warning$
3131               ""
3132             }
3133             { key sortify }
3134           if$
3135         }
3136         { organization sortify }
3137       if$
3138     }
3139     { author sort.format.names }
3140   if$
3141 }
3142
3143 FUNCTION { editor.organization.sort }
3144 {
3145   % added - GNP. Stack editor or organization for sorting (from alpha.bst).
3146   % Unlike alpha.bst, we need entire names, not abbreviations
3147
3148   editor empty.or.unknown
3149     { organization empty.or.unknown
3150         { key empty.or.unknown
3151             { "to sort, need editor, organization, or key in " cite$ * warning$
3152               ""
3153             }
3154             { key sortify }
3155           if$
3156         }
3157         { organization sortify }
3158       if$
3159     }
3160     { editor sort.format.names }
3161   if$
3162 }
3163
3164 FUNCTION { presort }
3165 {
3166   % Presort creates the bibentry's label via a call to calc.label, and then
3167   % sorts the entries based on entry type. Chicago.bst adds support for
3168   % including organizations as the sort key; the following is stolen from
3169   % alpha.bst.
3170
3171   calc.label sortify % recalculate bibitem label
3172   year field.or.null purify$ #-1 #4 substring$ * % add year
3173   "    "
3174   *
3175   type$ "book" =
3176   type$ "inbook" =
3177   or
3178     'author.editor.sort
3179     { type$ "proceedings" =
3180         'editor.organization.sort
3181         { type$ "manual" =
3182             'author.organization.sort
3183             'author.sort
3184           if$
3185         }
3186       if$
3187     }
3188   if$
3189   #1 entry.max$ substring$        % added for newapa
3190   'sort.label :=                  % added for newapa
3191   sort.label                      % added for newapa
3192   *
3193   "    "
3194   *
3195   title field.or.null
3196   sort.format.title
3197   *
3198   #1 entry.max$ substring$
3199   'sort.key$ :=
3200 }
3201
3202 ITERATE { presort }
3203
3204 SORT             % by label, year, author/editor, title
3205
3206 FUNCTION { initialize.extra.label.stuff }
3207 { #0 int.to.chr$ 'last.label :=
3208   "" 'next.extra :=
3209   #0 'last.extra.num :=
3210 }
3211
3212 FUNCTION { forward.pass }
3213 {
3214   % Pass through all entries, comparing current entry to last one.
3215   % Need to concatenate year to the stack (done by calc.label) to determine
3216   % if two entries are the same (see presort)
3217
3218   last.label
3219   % OLD:calc.label year field.or.null purify$ #-1 #4 substring$ * % add year
3220   % NEW:
3221   author.key.label year field.or.null purify$ #-1 #4 substring$ * % add year
3222   #1 entry.max$ substring$ =     % are they equal?
3223      { last.extra.num #1 + 'last.extra.num :=
3224        last.extra.num int.to.chr$ 'extra.label :=
3225      }
3226      { "a" chr.to.int$ 'last.extra.num :=
3227        "" 'extra.label :=
3228        % OLD: calc.label year field.or.null purify$ #-1 #4 substring$ * % add year
3229        % NEW:
3230        author.key.label year field.or.null purify$ #-1 #4 substring$ * % add year
3231        #1 entry.max$ substring$ 'last.label := % assign to last.label
3232      }
3233   if$
3234 }
3235
3236 FUNCTION { reverse.pass }
3237 {
3238   next.extra "b" =
3239     { "a" 'extra.label := }
3240      'skip$
3241   if$
3242   label.year extra.label * 'sort.year :=
3243   extra.label 'next.extra :=
3244 }
3245
3246 EXECUTE {initialize.extra.label.stuff}
3247
3248 ITERATE {forward.pass}
3249
3250 REVERSE {reverse.pass}
3251
3252 FUNCTION { bib.sort.order }
3253 {
3254   sort.label
3255   "    "
3256   *
3257   year field.or.null sortify
3258   *
3259   "    "
3260   *
3261   title field.or.null
3262   sort.format.title
3263   *
3264   #1 entry.max$ substring$
3265   'sort.key$ :=
3266 }
3267
3268 ITERATE { bib.sort.order }
3269
3270 SORT             % by sort.label, year, title --- giving final bib. order.
3271
3272 FUNCTION { begin.bib }
3273 {
3274   %% Set to #0 show 13-digit ISBN in preference to 10-digit ISBN.
3275   %% Set to #1 to show both 10-digit and 13-digit ISBNs.
3276   #1 'show-isbn-10-and-13 :=
3277
3278   "%%% -*-BibTeX-*-" writeln
3279   "%%% Do NOT edit. File created by BibTeX with style" writeln
3280   "%%% ACM-Reference-Format-Journals [18-Jan-2012]." writeln
3281   "" writeln
3282
3283   preamble$ empty.or.unknown
3284     'skip$
3285     { preamble$ writeln }
3286   if$
3287   "\begin{thebibliography}{00}" writeln
3288   ""                                                                         writeln
3289   "%%% ====================================================================" writeln
3290   "%%% NOTE TO THE USER: you can override these defaults by providing"       writeln
3291   "%%% customized versions of any of these macros before the \bibliography"  writeln
3292   "%%% command.  Each of them MUST provide its own final punctuation,"       writeln
3293   "%%% except for \shownote{}, \showDOI{}, and \showURL{}.  The latter two"  writeln
3294   "%%% do not use final punctuation, in order to avoid confusing it with"    writeln
3295   "%%% the Web address."                                                     writeln
3296   "%%%"                                                                      writeln
3297   "%%% To suppress output of a particular field, define its macro to expand" writeln
3298   "%%% to an empty string, or better, \unskip, like this:"                   writeln
3299   "%%%"                                                                      writeln
3300   "%%% \newcommand{\showDOI}[1]{\unskip}   % LaTeX syntax"                   writeln
3301   "%%%"                                                                      writeln
3302   "%%% \def \showDOI #1{\unskip}           % plain TeX syntax"               writeln
3303   "%%%"                                                                      writeln
3304   "%%% ====================================================================" writeln
3305   ""                                                                         writeln
3306
3307   %% ACM publications do not use CODEN, ISSN, and LCCN data, so their default
3308   %% macro wrappers expand to \unskip, discarding their values and unwanted
3309   %% space.
3310   %%
3311   %% For other publications, prior definitions like these may be useful:
3312   %%
3313   %%     Plain TeX:
3314   %%         \def \showCODEN     #1{CODEN #1.}
3315   %%         \def \showISSN      #1{ISSN #1.}
3316   %%         \def \showLCCN      #1{LCCN #1.}
3317   %%
3318   %%     LaTeX:
3319   %%         \newcommand{\showCODEN}[1]{CODEN #1.}
3320   %%         \newcommand{\showISSN}[1]#1{ISSN #1.}
3321   %%         \newcommand{\showLCCN}[1]{LCCN #1.}
3322
3323   "\ifx \showCODEN    \undefined \def \showCODEN     #1{\unskip}     \fi" writeln
3324   "\ifx \showDOI      \undefined \def \showDOI       #1{{\tt DOI:}\penalty0{#1}\ } \fi" writeln
3325   % ACM styles omit ISBNs, but they can be included by suitable definitions of
3326   % \showISBNx and \showISBNxiii before the .bbl file is read
3327   "\ifx \showISBNx    \undefined \def \showISBNx     #1{\unskip}     \fi" writeln
3328   "\ifx \showISBNxiii \undefined \def \showISBNxiii  #1{\unskip}     \fi" writeln
3329   "\ifx \showISSN     \undefined \def \showISSN      #1{\unskip}     \fi" writeln
3330   "\ifx \showLCCN     \undefined \def \showLCCN      #1{\unskip}     \fi" writeln
3331   "\ifx \shownote     \undefined \def \shownote      #1{#1}          \fi" writeln % NB: final period supplied by add.period$ above
3332   "\ifx \showarticletitle \undefined \def \showarticletitle #1{#1}   \fi" writeln
3333   "\ifx \showURL      \undefined \def \showURL       #1{#1}          \fi" writeln
3334 }
3335
3336 EXECUTE {begin.bib}
3337
3338 EXECUTE {init.state.consts}
3339
3340 ITERATE {call.type$}
3341
3342 FUNCTION { end.bib }
3343 {
3344   newline$
3345   "\end{thebibliography}"
3346   writeln
3347 }
3348
3349 EXECUTE {end.bib}
3350
3351 %%% End of ACM-Reference-Format-Journals.bst V1.00 - 18 January 2012
3352

Community Data Science Collective || Want to submit a patch?