Commit 7c525455451c0a7be4c6cdddde543b2c539dce9e

Authored by Melissa Wen
2 parents 76487a85 c446e6eb

Merge branch 'oss_2018' of http://softwarepublico.gov.br/gitlab/softwarepublico/…

…articles into oss_2018
icse2018/.gitignore
... ... @@ -1,26 +0,0 @@
1   -*.pdf
2   -*.log
3   -*.aux
4   -*.cfg
5   -*.glo
6   -*.idx
7   -*.toc
8   -*.ilg
9   -*.ind
10   -*.out
11   -*.lof
12   -*.lot
13   -*.bbl
14   -*.blg
15   -*.gls
16   -*.cut
17   -*.hd
18   -*.dvi
19   -*.ps
20   -*.thm
21   -*.tgz
22   -*.zip
23   -*.rpi
24   -*~
25   -*.fdb_latexmk
26   -*.fls
icse2018/ACM-Reference-Format.bst
... ... @@ -1,3238 +0,0 @@
1   -%%% -*-BibTeX-*-
2   -%%% ====================================================================
3   -%%% @BibTeX-style-file{
4   -%%% author = "Nelson H. F. Beebe, Boris Veytsman and Gerald Murray",
5   -%%% version = "2.1",
6   -%%% date = "14 June 2017",
7   -%%% filename = "ACM-Reference-Format.bst",
8   -%%% email = "borisv@lk.net, boris@varphi.com",
9   -%%% codetable = "ISO/ASCII",
10   -%%% keywords = "ACM Transactions bibliography style; BibTeX",
11   -%%% license = "public domain",
12   -%%% supported = "yes",
13   -%%% abstract = "",
14   -%%% }
15   -%%% ====================================================================
16   -
17   -%%% Revision history: see source in git
18   -
19   -ENTRY
20   - { address
21   - advisor
22   - archiveprefix
23   - author
24   - booktitle
25   - chapter
26   - city
27   - date
28   - edition
29   - editor
30   - eprint
31   - howpublished
32   - institution
33   - journal
34   - key
35   - month
36   - note
37   - number
38   - organization
39   - pages
40   - primaryclass
41   - publisher
42   - school
43   - series
44   - title
45   - type
46   - volume
47   - year
48   - % New keys recognized
49   - issue % UTAH: used in, e.g., ACM SIGSAM Bulletin and ACM Communications in Computer Algebra
50   - articleno
51   - eid
52   - day % UTAH: needed for newspapers, weeklies, bi-weeklies
53   - doi % UTAH
54   - url % UTAH
55   - bookpages % UTAH
56   - numpages
57   - lastaccessed % UTAH: used only for @Misc{...}
58   - coden % UTAH
59   - isbn % UTAH
60   - isbn-13 % UTAH
61   - issn % UTAH
62   - lccn % UTAH
63   - }
64   - {}
65   - { label.year extra.label sort.year sort.label basic.label.year}
66   -
67   -INTEGERS { output.state before.all mid.sentence after.sentence after.block }
68   -
69   -INTEGERS { show-isbn-10-and-13 } % initialized below in begin.bib
70   -
71   -INTEGERS { nameptr namesleft numnames }
72   -
73   -INTEGERS { multiresult }
74   -
75   -INTEGERS { len }
76   -
77   -INTEGERS { last.extra.num }
78   -
79   -STRINGS { s t t.org u }
80   -
81   -STRINGS { last.label next.extra }
82   -
83   -STRINGS { p1 p2 p3 page.count }
84   -
85   -
86   -FUNCTION { not }
87   -{
88   - { #0 }
89   - { #1 }
90   - if$
91   -}
92   -
93   -FUNCTION { and }
94   -{
95   - 'skip$
96   - { pop$ #0 }
97   - if$
98   -}
99   -
100   -FUNCTION { or }
101   -{
102   - { pop$ #1 }
103   - 'skip$
104   - if$
105   -}
106   -
107   -
108   -FUNCTION { dump.stack.1 }
109   -{
110   - duplicate$ "STACK[top] = [" swap$ * "]" * warning$
111   -}
112   -
113   -FUNCTION { dump.stack.2 }
114   -{
115   - duplicate$ "STACK[top ] = [" swap$ * "]" * warning$
116   - swap$
117   - duplicate$ "STACK[top-1] = [" swap$ * "]" * warning$
118   - swap$
119   -}
120   -
121   -FUNCTION { empty.or.unknown }
122   -{
123   - %% Examine the top stack entry, and push 1 if it is empty, or
124   - %% consists only of whitespace, or is a string beginning with two
125   - %% queries (??), and otherwise, push 0.
126   - %%
127   - %% This function provides a replacement for empty$, with the
128   - %% convenient feature that unknown values marked by two leading
129   - %% queries are treated the same as missing values, and thus, do not
130   - %% appear in the output .bbl file, and yet, their presence in .bib
131   - %% file(s) serves to mark values which are temporarily missing, but
132   - %% are expected to be filled in eventually once more data is
133   - %% obtained. The TeX User Group and BibNet bibliography archives
134   - %% make extensive use of this practice.
135   - %%
136   - %% An empty string cannot serve the same purpose, because just as in
137   - %% statistics data processing, an unknown value is not the same as an
138   - %% empty value.
139   - %%
140   - %% At entry: stack = ... top:[string]
141   - %% At exit: stack = ... top:[0 or 1]
142   -
143   - duplicate$ empty$
144   - { pop$ #1 }
145   - { #1 #2 substring$ "??" = }
146   - if$
147   -}
148   -
149   -FUNCTION { writeln }
150   -{
151   - %% In BibTeX style files, the sequences
152   - %%
153   - %% ... "one" "two" output
154   - %% ... "one" "two" output.xxx
155   - %%
156   - %% ship "one" to the output file, possibly following by punctuation,
157   - %% leaving the stack with
158   - %%
159   - %% ... "two"
160   - %%
161   - %% There is thus a one-string lag in output processing that must be
162   - %% carefully handled to avoid duplicating a string in the output
163   - %% file. Unless otherwise noted, all output.xxx functions leave
164   - %% just one new string on the stack, and that model should be born
165   - %% in mind when reading or writing function code.
166   - %%
167   - %% BibTeX's asynchronous buffering of output from strings from the
168   - %% stack is confusing because newline$ bypasses the buffer. It
169   - %% would have been so much easier for newline to be a character
170   - %% rather than a state of the output-in-progress.
171   - %%
172   - %% The documentation in btxhak.dvi is WRONG: it says
173   - %%
174   - %% newline$ Writes onto the bbl file what's accumulated in the
175   - %% output buffer. It writes a blank line if and only
176   - %% if the output buffer is empty. Since write$ does
177   - %% reasonable line breaking, you should use this
178   - %% function only when you want a blank line or an
179   - %% explicit line break.
180   - %%
181   - %% write$ Pops the top (string) literal and writes it on the
182   - %% output buffer (which will result in stuff being
183   - %% written onto the bbl file when the buffer fills
184   - %% up).
185   - %%
186   - %% Examination of the BibTeX source code shows that write$ does
187   - %% indeed behave as claimed, but newline$ sends a newline character
188   - %% directly to the output file, leaving the stack unchanged. The
189   - %% first line "Writes onto ... buffer." is therefore wrong.
190   - %%
191   - %% The original BibTeX style files almost always use "write$ newline$"
192   - %% in that order, so it makes sense to hide that pair in a private
193   - %% function like this one, named after a statement in Pascal,
194   - %% the programming language embedded in the BibTeX Web program.
195   -
196   - write$ % output top-of-stack string
197   - newline$ % immediate write of newline (not via stack)
198   -}
199   -
200   -FUNCTION { init.state.consts }
201   -{
202   - #0 'before.all :=
203   - #1 'mid.sentence :=
204   - #2 'after.sentence :=
205   - #3 'after.block :=
206   -}
207   -
208   -FUNCTION { output.nonnull }
209   -{ % Stack in: ... R S T Stack out: ... R T File out: S<comma><space>
210   - 's :=
211   - output.state mid.sentence =
212   - {
213   - ", " * write$
214   - }
215   - {
216   - output.state after.block =
217   - {
218   - add.period$ writeln
219   - "\newblock " write$
220   - }
221   - {
222   - output.state before.all =
223   - {
224   - write$
225   - }
226   - {
227   - add.period$ " " * write$
228   - }
229   - if$
230   - }
231   - if$
232   - mid.sentence 'output.state :=
233   - }
234   - if$
235   - s
236   -}
237   -
238   -FUNCTION { output.nonnull.dot.space }
239   -{ % Stack in: ... R S T Stack out: ... R T File out: S<dot><space>
240   - 's :=
241   - output.state mid.sentence = % { "<DEBUG output.nonnull.dot.space>. " * write$ }
242   - {
243   - ". " * write$
244   - }
245   - {
246   - output.state after.block =
247   - {
248   - add.period$ writeln "\newblock " write$
249   - }
250   - {
251   - output.state before.all =
252   - {
253   - write$
254   - }
255   - {
256   - add.period$ " " * write$
257   - }
258   - if$
259   - }
260   - if$
261   - mid.sentence 'output.state :=
262   - }
263   - if$
264   - s
265   -}
266   -
267   -FUNCTION { output.nonnull.remove }
268   -{ % Stack in: ... R S T Stack out: ... R T File out: S<space>
269   - 's :=
270   - output.state mid.sentence =
271   - {
272   - " " * write$
273   - }
274   - {
275   - output.state after.block =
276   - {
277   - add.period$ writeln "\newblock " write$
278   - }
279   - {
280   - output.state before.all =
281   - {
282   - write$
283   - }
284   - {
285   - add.period$ " " * write$
286   - }
287   - if$
288   - }
289   - if$
290   - mid.sentence 'output.state :=
291   - }
292   - if$
293   - s
294   -}
295   -
296   -FUNCTION { output.nonnull.removenospace }
297   -{ % Stack in: ... R S T Stack out: ... R T File out: S
298   - 's :=
299   - output.state mid.sentence =
300   - {
301   - "" * write$
302   - }
303   - {
304   - output.state after.block =
305   - {
306   - add.period$ writeln "\newblock " write$
307   - }
308   - {
309   - output.state before.all =
310   - {
311   - write$
312   - }
313   - {
314   - add.period$ " " * write$
315   - }
316   - if$
317   - }
318   - if$
319   - mid.sentence 'output.state :=
320   - }
321   - if$
322   - s
323   -}
324   -
325   -FUNCTION { output }
326   -{ % discard top token if empty, else like output.nonnull
327   - duplicate$ empty.or.unknown
328   - 'pop$
329   - 'output.nonnull
330   - if$
331   -}
332   -
333   -FUNCTION { output.dot.space }
334   -{ % discard top token if empty, else like output.nonnull.dot.space
335   - duplicate$ empty.or.unknown
336   - 'pop$
337   - 'output.nonnull.dot.space
338   - if$
339   -}
340   -
341   -FUNCTION { output.removenospace }
342   -{ % discard top token if empty, else like output.nonnull.removenospace
343   - duplicate$ empty.or.unknown
344   - 'pop$
345   - 'output.nonnull.removenospace
346   - if$
347   -}
348   -
349   -FUNCTION { output.check }
350   -{ % like output, but warn if key name on top-of-stack is not set
351   - 't :=
352   - duplicate$ empty.or.unknown
353   - { pop$ "empty " t * " in " * cite$ * warning$ }
354   - 'output.nonnull
355   - if$
356   -}
357   -
358   -FUNCTION { bibinfo.output.check }
359   -{ % like output.check, adding bibinfo field
360   - 't :=
361   - duplicate$ empty.or.unknown
362   - { pop$ "empty " t * " in " * cite$ * warning$ }
363   - { "\bibinfo{" t "}{" * * swap$ * "}" *
364   - output.nonnull }
365   - if$
366   -}
367   -
368   -FUNCTION { output.check.dot.space }
369   -{ % like output.dot.space, but warn if key name on top-of-stack is not set
370   - 't :=
371   - duplicate$ empty.or.unknown
372   - { pop$ "empty " t * " in " * cite$ * warning$ }
373   - 'output.nonnull.dot.space
374   - if$
375   -}
376   -
377   -FUNCTION { fin.block }
378   -{ % functionally, but not logically, identical to fin.entry
379   - add.period$
380   - writeln
381   -}
382   -
383   -FUNCTION { fin.entry }
384   -{
385   - add.period$
386   - writeln
387   -}
388   -
389   -FUNCTION { new.sentence }
390   -{ % update sentence state, with neither output nor stack change
391   - output.state after.block =
392   - 'skip$
393   - {
394   - output.state before.all =
395   - 'skip$
396   - { after.sentence 'output.state := }
397   - if$
398   - }
399   - if$
400   -}
401   -
402   -FUNCTION { fin.sentence }
403   -{
404   - add.period$
405   - write$
406   - new.sentence
407   - ""
408   -}
409   -
410   -FUNCTION { new.block }
411   -{
412   - output.state before.all =
413   - 'skip$
414   - { after.block 'output.state := }
415   - if$
416   -}
417   -
418   -FUNCTION { output.coden } % UTAH
419   -{ % output non-empty CODEN as one-line sentence (stack untouched)
420   - coden empty.or.unknown
421   - { }
422   - { "\showCODEN{" coden * "}" * writeln }
423   - if$
424   -}
425   -
426   -FUNCTION { format.articleno }
427   -{
428   - articleno empty.or.unknown not eid empty.or.unknown not and
429   - { "Both articleno and eid are defined for " cite$ * warning$ }
430   - 'skip$
431   - if$
432   - articleno empty.or.unknown eid empty.or.unknown and
433   - { "" }
434   - {
435   - numpages empty.or.unknown
436   - { "articleno or eid field, but no numpages field, in "
437   - cite$ * warning$ }
438   - { }
439   - if$
440   - eid empty.or.unknown
441   - { "Article \bibinfo{articleno}{" articleno * "}" * }
442   - { "Article \bibinfo{articleno}{" eid * "}" * }
443   - if$
444   - }
445   - if$
446   -}
447   -
448   -FUNCTION { format.year }
449   -{ % push year string or "[n. d.]" onto output stack
450   - %% Because year is a mandatory field, we always force SOMETHING
451   - %% to be output
452   - "\bibinfo{year}{"
453   - year empty.or.unknown
454   - { "[n. d.]" }
455   - { year }
456   - if$
457   - * "}" *
458   -}
459   -
460   -FUNCTION { format.day.month }
461   -{ % push "day month " or "month " or "" onto output stack
462   - day empty.or.unknown
463   - {
464   - month empty.or.unknown
465   - { "" }
466   - { "\bibinfo{date}{" month * "} " *}
467   - if$
468   - }
469   - {
470   - month empty.or.unknown
471   - { "" }
472   - { "\bibinfo{date}{" day * " " * month * "} " *}
473   - if$
474   - }
475   - if$
476   -}
477   -
478   -FUNCTION { format.day.month.year } % UTAH
479   -{ % if month is empty, push "" else push "(MON.)" or "(DD MON.)"
480   - % Needed for frequent periodicals: 2008. ... New York Times C-1, C-2, C-17 (23 Oct.)
481   - % acm-*.bst addition: prefix parenthesized date string with
482   - % ", Article nnn "
483   - articleno empty.or.unknown eid empty.or.unknown and
484   - { "" }
485   - { output.state after.block =
486   - {", " format.articleno * }
487   - { format.articleno }
488   - if$
489   - }
490   - if$
491   - " (" * format.day.month * format.year * ")" *
492   -}
493   -
494   -FUNCTION { output.day.month.year } % UTAH
495   -{ % if month is empty value, do nothing; else output stack top and
496   - % leave with new top string "(MON.)" or "(DD MON.)"
497   - % Needed for frequent periodicals: 2008. ... New York Times C-1, C-2, C-17 (23 Oct.)
498   - format.day.month.year
499   - output.nonnull.remove
500   -}
501   -
502   -FUNCTION { strip.doi } % UTAH
503   -{ % Strip any Web address prefix to recover the bare DOI, leaving the
504   - % result on the output stack, as recommended by CrossRef DOI
505   - % documentation.
506   - % For example, reduce "http://doi.acm.org/10.1145/1534530.1534545" to
507   - % "10.1145/1534530.1534545". That is later typeset and displayed as
508   - % doi:10.1145/1534530.1534545 as the LAST item in the reference list
509   - % entry. Publisher Web sites wrap this with a suitable link to a real
510   - % URL to resolve the DOI, and the master https://doi.org/ address is
511   - % preferred, since publisher-specific URLs can disappear in response
512   - % to economic events. All journals are encouraged by the DOI
513   - % authorities to use that typeset format and link procedures for
514   - % uniformity across all publications that include DOIs in reference
515   - % lists.
516   - % The numeric prefix is guaranteed to start with "10.", so we use
517   - % that as a test.
518   - % 2017-02-04 Added stripping of https:// (Boris)
519   - doi #1 #3 substring$ "10." =
520   - { doi }
521   - {
522   - doi 't := % get modifiable copy of DOI
523   -
524   - % Change https:// to http:// to strip both prefixes (BV)
525   -
526   - t #1 #8 substring$ "https://" =
527   - { "http://" t #9 t text.length$ #8 - substring$ * 't := }
528   - { }
529   - if$
530   -
531   - t #1 #7 substring$ "http://" =
532   - {
533   - t #8 t text.length$ #7 - substring$ 't :=
534   -
535   - "INTERNAL STYLE-FILE ERROR" 's :=
536   -
537   - % search for next "/" and assign its suffix to s
538   -
539   - { t text.length$ }
540   - {
541   - t #1 #1 substring$ "/" =
542   - {
543   - % save rest of string as true DOI (should be 10.xxxx/yyyy)
544   - t #2 t text.length$ #1 - substring$ 's :=
545   - "" 't := % empty string t terminates the loop
546   - }
547   - {
548   - % discard first character and continue loop: t <= substring(t,2,last)
549   - t #2 t text.length$ #1 - substring$ 't :=
550   - }
551   - if$
552   - }
553   - while$
554   -
555   - % check for valid DOI (should be 10.xxxx/yyyy)
556   - s #1 #3 substring$ "10." =
557   - { }
558   - { "unrecognized DOI substring " s * " in DOI value [" * doi * "]" * warning$ }
559   - if$
560   -
561   - s % push the stripped DOI on the output stack
562   -
563   - }
564   - {
565   - "unrecognized DOI value [" doi * "]" * warning$
566   - doi % push the unrecognized original DOI on the output stack
567   - }
568   - if$
569   - }
570   - if$
571   -}
572   -
573   -%
574   -% Change by BV: added standard prefix to URL
575   -%
576   -FUNCTION { output.doi } % UTAH
577   -{ % output non-empty DOI as one-line sentence (stack untouched)
578   - doi empty.or.unknown
579   - { }
580   - {
581   - %% NB: We want URLs at beginning of line to reduce likelihood of
582   - %% BibTeX's nasty line wrapping after column 79, which then requires
583   - %% manual (or automated) editing of the .bbl file to repair.
584   - %% The \url{} macro strips percent-newlines, and is thus safe in
585   - %% the presence of the line wrapping, but \path|...| and
586   - %% \verb|...| do not.
587   - "\showDOI{%" writeln
588   - "\url{https://doi.org/" strip.doi * "}}" * writeln
589   - }
590   - if$
591   -}
592   -
593   -FUNCTION { output.isbn } % UTAH
594   -{ % output non-empty ISBN-10 and/or ISBN-13 as one-line sentences (stack untouched)
595   - show-isbn-10-and-13
596   - {
597   - %% show both 10- and 13-digit ISBNs
598   - isbn empty.or.unknown
599   - { }
600   - {
601   - "\showISBNx{" isbn * "}" * writeln
602   - }
603   - if$
604   - isbn-13 empty.or.unknown
605   - { }
606   - {
607   - "\showISBNxiii{" isbn-13 * "}" * writeln
608   - }
609   - if$
610   - }
611   - {
612   - %% show 10-digit ISBNs only if 13-digit ISBNs not available
613   - isbn-13 empty.or.unknown
614   - {
615   - isbn empty.or.unknown
616   - { }
617   - {
618   - "\showISBNx{" isbn * "}" * writeln
619   - }
620   - if$
621   - }
622   - {
623   - "\showISBNxiii{" isbn-13 * "}" * writeln
624   - }
625   - if$
626   - }
627   - if$
628   -}
629   -
630   -FUNCTION { output.issn } % UTAH
631   -{ % output non-empty ISSN as one-line sentence (stack untouched)
632   - issn empty.or.unknown
633   - { }
634   - { "\showISSN{" issn * "}" * writeln }
635   - if$
636   -}
637   -
638   -FUNCTION { output.issue }
639   -{ % output non-empty issue number as a one-line sentence (stack untouched)
640   - issue empty.or.unknown
641   - { }
642   - { "Issue " issue * "." * writeln }
643   - if$
644   -}
645   -
646   -FUNCTION { output.lccn } % UTAH
647   -{ % return with stack untouched
648   - lccn empty.or.unknown
649   - { }
650   - { "\showLCCN{" lccn * "}" * writeln }
651   - if$
652   -}
653   -
654   -FUNCTION { output.note } % UTAH
655   -{ % return with stack empty
656   - note empty.or.unknown
657   - { }
658   - { "\shownote{" note add.period$ * "}" * writeln }
659   - if$
660   -}
661   -
662   -FUNCTION { output.note.check } % UTAH
663   -{ % return with stack empty
664   - note empty.or.unknown
665   - { "empty note in " cite$ * warning$ }
666   - { "\shownote{" note add.period$ * "}" * writeln }
667   - if$
668   -}
669   -
670   -FUNCTION { output.eprint } %
671   -{ % return with stack empty
672   - eprint empty.or.unknown
673   - { }
674   - { "\showeprint"
675   - archiveprefix empty.or.unknown
676   - { }
677   - { "[" archiveprefix "l" change.case$ "]" * * * }
678   - if$
679   - "{" *
680   - primaryclass empty.or.unknown
681   - { }
682   - { primaryclass "/" * *}
683   - if$
684   - eprint "}" * *
685   - writeln
686   - }
687   - if$
688   -}
689   -
690   -
691   -%
692   -% Changes by BV 2011/04/15. Do not output
693   -% url if doi is defined
694   -%
695   -FUNCTION { output.url } % UTAH
696   -{ % return with stack untouched
697   - % output URL and associated lastaccessed fields
698   - doi empty.or.unknown
699   - {
700   - url empty.or.unknown
701   - { }
702   - {
703   - %% NB: We want URLs at beginning of line to reduce likelihood of
704   - %% BibTeX's nasty line wrapping after column 79, which would require
705   - %% manual (or automated) editing of the .bbl file to repair. However,
706   - %% the \url{} macro handles the unwrapping job automatically.
707   - "\showURL{%" writeln
708   - lastaccessed empty.or.unknown
709   - { "" }
710   - { "Retrieved " lastaccessed * " from " * }
711   - if$
712   -
713   - %% The URL field may contain a semicolon-separated list of Web
714   - %% addresses, and we locate and wrap each of them in \url{...}.
715   - %% The simplistic approach of putting the entire list into the
716   - %% macro argument is that the semicolons are typeset in a
717   - %% typewriter font, and no space follows them.
718   - %%
719   - %% We therefore replace the original code
720   - %% "\url{" * url * "}}" * writeln
721   - %% with this character-at-a-time loop:
722   -
723   - "\url{" *
724   -
725   - url 't := % get modifiable copy of URL list
726   -
727   - { t text.length$ }
728   - {
729   - t #1 #1 substring$ ";" =
730   - { % then split argument at separator
731   - "};" * writeln
732   - "\url{"
733   - }
734   - { % else concatenate nonblank character to argument
735   - t #1 #1 substring$ " " =
736   - { }
737   - { t #1 #1 substring$ * }
738   - if$
739   - }
740   - if$
741   -
742   - t #2 t text.length$ #1 - substring$ 't :=
743   - }
744   - while$
745   -
746   - "}}" * writeln
747   - }
748   - if$
749   - }
750   - { }
751   - if$
752   -}
753   -
754   -FUNCTION { output.year.check }
755   -{ % warn if year empty, output top string and leave " YEAR<label>" on stack in mid-sentence
756   - year empty.or.unknown
757   - { "empty year in " cite$ * warning$
758   - write$
759   - " \bibinfo{year}{[n. d.]}"
760   - "\natexlab{" extra.label * "}" * *
761   - mid.sentence 'output.state :=
762   - }
763   - { write$
764   - " \bibinfo{year}{" year * "}" *
765   - "\natexlab{" extra.label * "}" * *
766   - mid.sentence 'output.state :=
767   - }
768   - if$
769   -}
770   -
771   -
772   -FUNCTION { le }
773   -{
774   - %% test whether first number is less than or equal to second number
775   - %% stack in: n1 n2
776   - %% stack out: if n1 <= n2 then 1 else 0
777   -
778   - %% "DEBUG: le " cite$ * warning$
779   - > { #0 } { #1 } if$
780   -}
781   -
782   -FUNCTION { ge }
783   -{
784   - %% test whether first number is greater than or equal to second number
785   - %% stack in: n1 n2
786   - %% stack out: if n1 >= n2 then 1 else 0
787   -
788   - %% "DEBUG: ge " cite$ * warning$
789   - < { #0 } { #1 } if$
790   -}
791   -
792   -FUNCTION { is.leading.digit }
793   -{
794   - %% test whether first character of string is a digit
795   - %% stack in: string
796   - %% stack out: if first-char-is-digit then 1 else 0
797   -
798   - #1 #1 substring$ % replace string by string[1:1]
799   - duplicate$ % string[1:1] string[1:1]
800   - chr.to.int$
801   - "0" chr.to.int$ swap$ le % "0" <= string[1:1] --> 0-or-1
802   - swap$ % 0-or-1 string[1:1]
803   - chr.to.int$
804   - "9" chr.to.int$ le % string[1:1} <= "9" --> 0-or-1
805   - and
806   -}
807   -
808   -FUNCTION { skip.digits }
809   -{
810   - %% skip over leading digits in string
811   - %% stack in: string
812   - %% stack out: rest-of-string leading-digits
813   -
814   - %% "DEBUG: enter skip.digits " cite$ * warning$
815   -
816   - %% dump.stack.1
817   -
818   - duplicate$
819   - 't :=
820   - 't.org :=
821   - "" 'u :=
822   -
823   - { t text.length$ }
824   - {
825   - %% "=================DEBUG: skip.digits t = [" t * "]" * warning$
826   - t is.leading.digit
827   - { t #2 t text.length$ #1 - substring$ }
828   - {
829   - t 'u :=
830   - ""
831   - }
832   - if$
833   - 't :=
834   - }
835   - while$
836   -
837   - u % rest of string
838   - t.org #1 t.org text.length$ u text.length$ - substring$ % leading digits
839   -
840   - %% "DEBUG: t.org = [" t.org * "]" * warning$
841   - %% "DEBUG: u = [" u * "]" * warning$
842   -
843   - %% dump.stack.2
844   -
845   - %% "DEBUG: leave skip.digits " cite$ * warning$
846   -}
847   -
848   -FUNCTION { skip.nondigits }
849   -{
850   - %% skip over leading nondigits in string
851   - %% stack in: string
852   - %% stack out: rest-of-string
853   -
854   - %% "DEBUG: enter skip.nondigits " cite$ * warning$
855   -
856   - 't :=
857   - "" 'u :=
858   -
859   - { t text.length$ }
860   - {
861   - %% "=================DEBUG: skip.nondigits t = [" t * "]" * warning$
862   - t is.leading.digit
863   - {
864   - t 'u :=
865   - ""
866   - }
867   - { t #2 t text.length$ #1 - substring$ }
868   - if$
869   - 't :=
870   - }
871   - while$
872   -
873   - u % rest of string
874   -
875   - %% dump.stack.1
876   - %% "DEBUG: leave skip.nondigits " cite$ * warning$
877   -}
878   -
879   -FUNCTION { parse.next.number }
880   -{
881   - %% stack in: string
882   - %% stack out: rest-of-string next-numeric-part-of-string
883   - %% Example:
884   - %% stack in: "123:1--123:59"
885   - %% stack out: ":1--123:59" "123"
886   -
887   - 's :=
888   - s skip.nondigits 's :=
889   - s skip.digits
890   -}
891   -
892   -FUNCTION { reduce.pages.to.page.count }
893   -{
894   - %% Stack in: arbitrary-and-unused
895   - %% Stack out: unchanged
896   - %%
897   - %% For the new-style pagination with article number and numpages or
898   - %% pages, we expect to have BibTeX entries containing something like
899   - %% articleno = "17",
900   - %% pages = "1--23",
901   - %% with output "Article 17, 23 pages",
902   - %% or
903   - %% articleno = "17",
904   - %% numpages = "23",
905   - %% with output "Article 17, 23 pages",
906   - %% or
907   - %% articleno = "17",
908   - %% pages = "17:1--17:23",
909   - %% with output "Article 17, 23 pages",
910   - %%
911   - %% If articleno is missing or empty, then we should output "1--23",
912   - %% "23" (with a warning of a missing articleno), or "17:1--17:23",
913   - %% respectively.
914   -
915   - %% "DEBUG: enter reduce.pages.to.page.count " cite$ * warning$
916   -
917   - %% "DEBUG: pages = [" pages * "]" * warning$
918   -
919   - pages
920   - parse.next.number 'p1 :=
921   - parse.next.number 'p2 :=
922   - parse.next.number 'p3 :=
923   - parse.next.number 'page.count :=
924   -
925   - duplicate$
926   - empty.or.unknown
927   - { }
928   - {
929   - duplicate$ "unexpected trailing garbage [" swap$ *
930   - "] after n:p1--n:p2 in pages = [" *
931   - pages *
932   - "] in " *
933   - cite$ *
934   - warning$
935   - }
936   - if$
937   -
938   - pop$
939   -
940   - %% "DEBUG: reduce.pages.to.page.count: "
941   - %% " p1 = " p1 * *
942   - %% " p2 = " p2 * *
943   - %% " p3 = " p3 * *
944   - %% " p4 = " page.count * *
945   - %% " in " cite$ * * warning$
946   -
947   - p1 p3 = p2 "1" = and numpages empty.or.unknown and
948   - { "INFO: reduced pages = [" pages * "] to numpages = [" * page.count * "]" * warning$ }
949   - {
950   - numpages empty.or.unknown
951   - { pages }
952   - { numpages }
953   - if$
954   - 'page.count :=
955   - }
956   - if$
957   -
958   - p1 "1" = p3 empty.or.unknown and numpages empty.or.unknown and
959   - {
960   - p2 'page.count :=
961   - "INFO: reduced pages = [" pages * "] to numpages = [" * page.count * "]" * warning$
962   - }
963   - {
964   - numpages empty.or.unknown
965   - { pages }
966   - { numpages }
967   - if$
968   - 'page.count :=
969   - }
970   - if$
971   -
972   - %% "DEBUG: leave reduce.pages.to.page.count " cite$ * warning$
973   -}
974   -
975   -FUNCTION { new.block.checkb }
976   -{ % issue a new.block only if at least one of top two stack strings is not empty
977   - empty.or.unknown
978   - swap$ empty.or.unknown
979   - and
980   - 'skip$
981   - 'new.block
982   - if$
983   -}
984   -
985   -FUNCTION { field.or.null }
986   -{ % convert empty value to null string, else return value
987   - duplicate$ empty.or.unknown
988   - { pop$ "" }
989   - 'skip$
990   - if$
991   -}
992   -
993   -
994   -
995   -FUNCTION { emphasize }
996   -{ % emphasize a non-empty top string on the stack (WITHOUT italic correction)