source: doc/papers/OOPSLA17/ACM-Reference-Format.bst @ 5fdaeab1

Last change on this file since 5fdaeab1 was f4e3419d, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

restructure paper documents

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