forked from mikesperber/hopl-4-emacs-lisp
/
ACM-HOPL-Reference-Format.bst
4169 lines (3828 loc) · 121 KB
/
ACM-HOPL-Reference-Format.bst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%%% -*-BibTeX-*-
%%% ====================================================================
%%% @BibTeX-style-file{
%%% author = "Nelson H. F. Beebe, Boris Veytsman and Gerald Murray",
%%% version = "2.1",
%%% date = "14 June 2017",
%%% filename = "ACM-Reference-Format.bst",
%%% email = "borisv@lk.net, boris@varphi.com",
%%% codetable = "ISO/ASCII",
%%% keywords = "ACM Transactions bibliography style; BibTeX",
%%% license = "public domain",
%%% supported = "yes",
%%% abstract = "",
%%% }
%%% ====================================================================
%%% Revision history: see source in git
ENTRY
{ address
advisor
archiveprefix
author
booktitle
chapter
city
date
edition
editor
eprint
eprinttype
eprintclass
howpublished
institution
journal
key
location
month
note
number
organization
pages
primaryclass
publisher
school
series
title
type
volume
year
% New keys recognized
issue % UTAH: used in, e.g., ACM SIGSAM Bulletin and ACM Communications in Computer Algebra
articleno
eid
day % UTAH: needed for newspapers, weeklies, bi-weeklies
doi % UTAH
url % UTAH
bookpages % UTAH
numpages
lastaccessed % UTAH: used only for @Misc{...}
coden % UTAH
isbn % UTAH
isbn-13 % UTAH
issn % UTAH
lccn % UTAH
archivedrepository archivedurl archivedurladdon archiveddate
synopsis
excerpt
urlprefix urladdon urldate
secondurlprefix secondurl secondurladdon secondurldate
thirdurlprefix thirdurl thirdurladdon thirdurldate
videourl videourladdon videourldate
slidesurl slidesurladdon slidesurldate
% director producer performer composer conductor choreographer writer bookby musicby lyricsby
% duration portion
% eformat medium channel
% recordedvenue recordedlocation recordeddate
titleaddon
journaldate
}
{}
{ single.year label label.year extra.label sort.year sort.label basic.label.year }
INTEGERS { output.state before.all mid.sentence after.sentence after.block }
INTEGERS { show-isbn-10-and-13 } % initialized below in begin.bib
INTEGERS { nameptr namesleft numnames }
INTEGERS { multiresult }
INTEGERS { len flag carry }
INTEGERS { last.extra.num }
STRINGS { s t t.org u }
STRINGS { last.label next.extra }
STRINGS { p1 p2 p3 page.count }
%%% Guy Steele January 2020:
% In order to refactor the processing of dates and urls, we introduce
% a new convention that if the name of a function includes the word
% "given" then that function takes arguments on the stack rather than
% grabbing values from entry fields. For example, a function named
% "format.day.month.year" (as always) examines the day, month, and
% year fields of an entry and returns one string on the stack, but a
% function named "format.given.day.month.year" takes three strings on
% the stack (where the topmost one is the "year" argument) and returns
% one string on the stack. A conventional implementation of such a
% function may begin by assigning the arguments on the stack to
% "local variables" (think of them as local parameter names).
% Furthermore we here introduce the convention that such parameter
% names begin with a dot. All such names that are used within this
% file are declared here. Such names can also be used for storing
% the results of a function that returns many values.
STRINGS { .np }
INTEGERS { .sepyear }
STRINGS { .extrayear .extramonth .extraday }
STRINGS { .year .month .day .hour
.minute .second .timezone .season
.endyear .endmonth .endday .endhour
.endminute .endsecond .endtimezone .endseason }
INTEGERS { .isrange }
STRINGS { .urlprefix .url .urladdon .dateprefix .date .archivedurl .archivedurladdon .archiveddate }
%%% Guy Steele January 2020:
% To help prevent conflicting uses of local variables, we also
% introduce the convention that a local variable "yyy" needed by a
% helper function named "xxx" may be called ".xxx.yyy" .
STRINGS { .join.temp }
FUNCTION { not }
{
{ #0 }
{ #1 }
if$
}
FUNCTION { and }
{
'skip$
{ pop$ #0 }
if$
}
FUNCTION { or }
{
{ pop$ #1 }
'skip$
if$
}
FUNCTION { dump.stack.1 }
{
duplicate$ "STACK[top] = [" swap$ * "]" * warning$
}
FUNCTION { dump.stack.2 }
{
duplicate$ "STACK[top ] = [" swap$ * "]" * warning$
swap$
duplicate$ "STACK[top-1] = [" swap$ * "]" * warning$
swap$
}
FUNCTION { empty.or.unknown }
{
%% Examine the top stack entry, and push 1 if it is empty, or
%% consists only of whitespace, or is a string beginning with two
%% queries (??), and otherwise, push 0.
%%
%% This function provides a replacement for empty$, with the
%% convenient feature that unknown values marked by two leading
%% queries are treated the same as missing values, and thus, do not
%% appear in the output .bbl file, and yet, their presence in .bib
%% file(s) serves to mark values which are temporarily missing, but
%% are expected to be filled in eventually once more data is
%% obtained. The TeX User Group and BibNet bibliography archives
%% make extensive use of this practice.
%%
%% An empty string cannot serve the same purpose, because just as in
%% statistics data processing, an unknown value is not the same as an
%% empty value.
%%
%% At entry: stack = ... top:[string]
%% At exit: stack = ... top:[0 or 1]
duplicate$ empty$
{ pop$ #1 }
{ #1 #2 substring$ "??" = }
if$
}
FUNCTION { field.or.null }
{ % convert empty value to null string, else return value
duplicate$ empty.or.unknown
{ pop$ "" }
'skip$
if$
}
FUNCTION { string.parameter }
{ % stack in: value quotedname
% Assigns the given value (possibly converted to empty string)
% to the given quotedname.
swap$ field.or.null swap$ :=
}
FUNCTION { integer.parameter }
{ % stack in: value quotedname
% Assigns the given value to the given quotedname.
:=
}
FUNCTION { writeln }
{
%% In BibTeX style files, the sequences
%%
%% ... "one" "two" output
%% ... "one" "two" output.xxx
%%
%% ship "one" to the output file, possibly following by punctuation,
%% leaving the stack with
%%
%% ... "two"
%%
%% There is thus a one-string lag in output processing that must be
%% carefully handled to avoid duplicating a string in the output
%% file. Unless otherwise noted, all output.xxx functions leave
%% just one new string on the stack, and that model should be born
%% in mind when reading or writing function code.
%%
%% BibTeX's asynchronous buffering of output from strings from the
%% stack is confusing because newline$ bypasses the buffer. It
%% would have been so much easier for newline to be a character
%% rather than a state of the output-in-progress.
%%
%% The documentation in btxhak.dvi is WRONG: it says
%%
%% newline$ Writes onto the bbl file what's accumulated in the
%% output buffer. It writes a blank line if and only
%% if the output buffer is empty. Since write$ does
%% reasonable line breaking, you should use this
%% function only when you want a blank line or an
%% explicit line break.
%%
%% write$ Pops the top (string) literal and writes it on the
%% output buffer (which will result in stuff being
%% written onto the bbl file when the buffer fills
%% up).
%%
%% Examination of the BibTeX source code shows that write$ does
%% indeed behave as claimed, but newline$ sends a newline character
%% directly to the output file, leaving the stack unchanged. The
%% first line "Writes onto ... buffer." is therefore wrong.
%%
%% The original BibTeX style files almost always use "write$ newline$"
%% in that order, so it makes sense to hide that pair in a private
%% function like this one, named after a statement in Pascal,
%% the programming language embedded in the BibTeX Web program.
write$ % output top-of-stack string
newline$ % immediate write of newline (not via stack)
}
FUNCTION { init.state.consts }
{
#0 'before.all :=
#1 'mid.sentence :=
#2 'after.sentence :=
#3 'after.block :=
}
FUNCTION { output.nonnull }
{ % Stack in: ... R S T Stack out: ... R T File out: S<comma><space>
's :=
output.state mid.sentence =
{
", " * write$
}
{
output.state after.block =
{
add.period$ writeln
"\newblock " write$
}
{
output.state before.all =
{
write$
}
{
add.period$ " " * write$
}
if$
}
if$
mid.sentence 'output.state :=
}
if$
s
}
FUNCTION { output.nonnull.dot.space }
{ % Stack in: ... R S T Stack out: ... R T File out: S<dot><space>
's :=
output.state mid.sentence = % { "<DEBUG output.nonnull.dot.space>. " * write$ }
{
". " * write$
}
{
output.state after.block =
{
add.period$ writeln "\newblock " write$
}
{
output.state before.all =
{
write$
}
{
add.period$ " " * write$
}
if$
}
if$
mid.sentence 'output.state :=
}
if$
s
}
FUNCTION { output.nonnull.remove }
{ % Stack in: ... R S T Stack out: ... R T File out: S<space>
's :=
output.state mid.sentence =
{
" " * write$
}
{
output.state after.block =
{
add.period$ writeln "\newblock " write$
}
{
output.state before.all =
{
write$
}
{
add.period$ " " * write$
}
if$
}
if$
mid.sentence 'output.state :=
}
if$
s
}
FUNCTION { output.nonnull.removenospace }
{ % Stack in: ... R S T Stack out: ... R T File out: S
's :=
output.state mid.sentence =
{
"" * write$
}
{
output.state after.block =
{
add.period$ writeln "\newblock " write$
}
{
output.state before.all =
{
write$
}
{
add.period$ " " * write$
}
if$
}
if$
mid.sentence 'output.state :=
}
if$
s
}
FUNCTION { output }
{ % discard top token if empty, else like output.nonnull
duplicate$ empty.or.unknown
'pop$
'output.nonnull
if$
}
FUNCTION { output.dot.space }
{ % discard top token if empty, else like output.nonnull.dot.space
duplicate$ empty.or.unknown
'pop$
'output.nonnull.dot.space
if$
}
FUNCTION { output.removenospace }
{ % discard top token if empty, else like output.nonnull.removenospace
duplicate$ empty.or.unknown
'pop$
'output.nonnull.removenospace
if$
}
FUNCTION { output.check }
{ % like output, but warn if key name on top-of-stack is not set
't :=
duplicate$ empty.or.unknown
{ pop$ "empty " t * " in " * cite$ * warning$ }
'output.nonnull
if$
}
FUNCTION { bibinfo.output.check }
{ % like output.check, adding bibinfo field
't :=
duplicate$ empty.or.unknown
{ pop$ "empty " t * " in " * cite$ * warning$ }
{ "\bibinfo{" t "}{" * * swap$ * "}" *
output.nonnull }
if$
}
FUNCTION { output.check.dot.space }
{ % like output.dot.space, but warn if key name on top-of-stack is not set
't :=
duplicate$ empty.or.unknown
{ pop$ "empty " t * " in " * cite$ * warning$ }
'output.nonnull.dot.space
if$
}
FUNCTION { fin.block }
{ % functionally, but not logically, identical to fin.entry
add.period$
writeln
}
FUNCTION { fin.entry }
{
add.period$
writeln
}
FUNCTION { new.sentence }
{ % update sentence state, with neither output nor stack change
output.state after.block =
'skip$
{
output.state before.all =
'skip$
{ after.sentence 'output.state := }
if$
}
if$
}
FUNCTION { fin.sentence }
{
add.period$
write$
new.sentence
""
}
FUNCTION { new.block }
{
output.state before.all =
'skip$
{ after.block 'output.state := }
if$
}
FUNCTION { split.at }
{ % Stack in: ... str sep
% Stack out: ... str-after-sep-or-empty str-before-sep-or-str was-sep-found
% This works only of the specified sep has no special characters,
% because we depend on text.length$ to get an accurate string length for sep.
's :=
duplicate$
't :=
't.org :=
"" 'u :=
#0 'flag :=
{ t "" = not }
{
t #1 s text.length$ substring$ s =
{
t s text.length$ #1 + global.max$ substring$ 'u :=
t.org #1 t.org text.length$ t text.length$ - substring$ 't.org :=
#1 'flag :=
"" 't := % terminate the loop
}
{
t #2 global.max$ substring$ 't :=
}
if$
}
while$
u t.org flag
}
FUNCTION { le }
{
%% test whether first number is less than or equal to second number
%% stack in: n1 n2
%% stack out: if n1 <= n2 then 1 else 0
%% "DEBUG: le " cite$ * warning$
> { #0 } { #1 } if$
}
FUNCTION { ge }
{
%% test whether first number is greater than or equal to second number
%% stack in: n1 n2
%% stack out: if n1 >= n2 then 1 else 0
%% "DEBUG: ge " cite$ * warning$
< { #0 } { #1 } if$
}
FUNCTION { is.leading.digit }
{ duplicate$ "" =
{ pop$ #0 }
{
%% test whether first character of string is a digit
%% stack in: string
%% stack out: if first-char-is-digit then 1 else 0
#1 #1 substring$ % replace string by string[1:1]
duplicate$ % string[1:1] string[1:1]
chr.to.int$
"0" chr.to.int$ swap$ le % "0" <= string[1:1] --> 0-or-1
swap$ % 0-or-1 string[1:1]
chr.to.int$
"9" chr.to.int$ le % string[1:1} <= "9" --> 0-or-1
and
}
if$
}
FUNCTION { is.leading.letter.or.digit }
{
%% test whether first character of string is a letter or digit
%% stack in: string
%% stack out: if first-char-is-letter-or-digit then 1 else 0
duplicate$ "" =
{ pop$ #0 }
{
#1 #1 substring$ % replace string by string[1:1]
duplicate$ duplicate$ % ... chr chr chr
chr.to.int$ "a" chr.to.int$ swap$ le
swap$
chr.to.int$ "z" chr.to.int$ le
and % ... chr islowercase
swap$ duplicate$
duplicate$ % ... islowercase chr chr chr
chr.to.int$ "A" chr.to.int$ swap$ le
swap$
chr.to.int$ "Z" chr.to.int$ le
and % ... islowercase chr isuppercase
swap$ duplicate$ % ... islowercase isuppercase chr chr
chr.to.int$ "0" chr.to.int$ swap$ le
swap$
chr.to.int$ "9" chr.to.int$ le
and % ... islowercase isuppercase isdigit
or or
}
if$
}
FUNCTION { split.digits }
{
%% split off leading digits in string
%% stack in: string
%% stack out: rest-of-string leading-digits
%% "DEBUG: enter split.digits " cite$ * warning$
%% dump.stack.1
duplicate$
't :=
't.org :=
"" 'u :=
{ t "" = not }
{
%% "=================DEBUG: split.digits t = [" t * "]" * warning$
t is.leading.digit
{ t #2 global.max$ substring$ }
{
t 'u :=
""
}
if$
't :=
}
while$
u % rest of string
t.org #1 t.org text.length$ u text.length$ - substring$ % leading digits
%% "DEBUG: t.org = [" t.org * "]" * warning$
%% "DEBUG: u = [" u * "]" * warning$
%% dump.stack.2
%% "DEBUG: leave split.digits " cite$ * warning$
}
FUNCTION { split.nondigits }
{
%% split off leading nondigits in string
%% stack in: string
%% stack out: rest-of-string leading-nondigits
%% "DEBUG: enter split.nondigits " cite$ * warning$
%% dump.stack.1
duplicate$
't :=
't.org :=
"" 'u :=
{ t text.length$ }
{
t is.leading.digit not
{ t #2 t text.length$ #1 - substring$ }
{
t 'u :=
""
}
if$
't :=
}
while$
u % rest of string
t.org #1 t.org text.length$ u text.length$ - substring$ % leading nondigits
%% dump.stack.2
%% "DEBUG: leave split.nondigits " cite$ * warning$
}
FUNCTION { skip.nondigits }
{
%% skip over leading nondigits in string
%% stack in: string
%% stack out: rest-of-string
%% "DEBUG: enter skip.nondigits " cite$ * warning$
't :=
"" 'u :=
{ t text.length$ }
{
%% "=================DEBUG: skip.nondigits t = [" t * "]" * warning$
t is.leading.digit
{
t 'u :=
""
}
{ t #2 t text.length$ #1 - substring$ }
if$
't :=
}
while$
u % rest of string
%% dump.stack.1
%% "DEBUG: leave skip.nondigits " cite$ * warning$
}
FUNCTION { strip.leading.zero.digits }
{
{ duplicate$ duplicate$ "" = not swap$ #1 #1 substring$ "0" = and }
{ #2 global.max$ substring$ }
while$
}
%%% Guy Steele January 2020: two functions "wrap" and "join" that can
% greatly reduce the number of conditional tests needed elsewhere.
FUNCTION { wrap }
{ % Wrap a middle string with two enclosing strings.
% Result is nonempty only if middle string is nonempty.
% Takes three arguments on stack. If second argument is empty.or.unknown,
% return empty string; otherwise concatenate the three strings.
swap$ duplicate$ empty.or.unknown
{ pop$ pop$ pop$ "" }
{ swap$ * * }
if$
}
FUNCTION { join }
{ % Join two outside strings with a separator.
% Result is nonempty only if both outside strings are nonempty.
% Takes three arguments on stack. Four cases:
% If first and third arguments are empty.or.unknown, return empty string.
% If only third argument is empty.or.unknown, return first argument.
% If only first argument is empty.or.unknown, return third argument.
% Otherwise, concatenate the three strings.
duplicate$ empty.or.unknown
{ % Third argument is empty.or.unknown
pop$ pop$ field.or.null
}
{ % Third argument is not empty
'.join.temp :=
swap$ duplicate$ empty.or.unknown
{ % First argument is empty.or.unknown
pop$ pop$ .join.temp
}
{ % First argument is not empty
swap$ * .join.temp *
}
if$
}
if$
}
FUNCTION { joinboth }
{ % Join two outside strings with a separator.
% Result is nonempty only if both outside strings are nonempty.
% Takes three arguments on stack. Four cases:
% If first and third arguments are empty.or.unknown, return empty string.
% If only third argument is empty.or.unknown, return empty string.
% If only first argument is empty.or.unknown, return empty string.
% Otherwise, concatenate the three strings.
duplicate$ empty.or.unknown
{ % Third argument is empty.or.unknown
pop$ pop$ pop$ ""
}
{ % Third argument is not empty
'.join.temp :=
swap$ duplicate$ empty.or.unknown
{ % First argument is empty.or.unknown
pop$ pop$ ""
}
{ % First argument is not empty
swap$ * .join.temp *
}
if$
}
if$
}
FUNCTION { joinfirst }
{ % Join two outside strings with a separator.
% Result is nonempty only if first outside string is nonempty.
% Takes three arguments on stack. Four cases:
% If first and third arguments are empty.or.unknown, return empty string.
% If only third argument is empty.or.unknown, return first argument.
% If only first argument is empty.or.unknown, return empty string.
% Otherwise, concatenate the three strings.
duplicate$ empty.or.unknown
{ % Third argument is empty.or.unknown
pop$ pop$ field.or.null
}
{ % Third argument is not empty
'.join.temp :=
swap$ duplicate$ empty.or.unknown
{ % First argument is empty.or.unknown
pop$ pop$ ""
}
{ % First argument is not empty
swap$ * .join.temp *
}
if$
}
if$
}
FUNCTION { joinsecond }
{ % Join two outside strings with a separator.
% Result is nonempty only if second outside string is nonempty.
% Takes three arguments on stack. Four cases:
% If first and third arguments are empty.or.unknown, return empty string.
% If only third argument is empty.or.unknown, return empty string.
% If only first argument is empty.or.unknown, return third argument.
% Otherwise, concatenate the three strings.
duplicate$ empty.or.unknown
{ % Third argument is empty.or.unknown
pop$ pop$ pop$ ""
}
{ % Third argument is not empty
'.join.temp :=
swap$ duplicate$ empty.or.unknown
{ % First argument is empty.or.unknown
pop$ pop$ .join.temp
}
{ % First argument is not empty
swap$ * .join.temp *
}
if$
}
if$
}
%%% Guy Steele January 2020: another function "wrap.bibinfo"
% for conveniently wrapping \bibinfo commands around strings
FUNCTION { wrap.bibinfo }
{ % Stack in: ... str info
% Takes two arguments on stack. If str is empty.or.unknown,
% return empty string; otherwise wrap str in a \bibinfo
% macro call "\bibinfo{info}{str}".
swap$ duplicate$ empty.or.unknown
{ pop$ pop$ "" }
{ swap$ "\bibinfo{" swap$ * "}{" * swap$ * "}" * }
if$
}
FUNCTION { output.coden } % UTAH
{ % output non-empty CODEN as one-line sentence (stack untouched)
coden empty.or.unknown
{ }
{ "\showCODEN{" coden * "}" * writeln }
if$
}
%%% Guy Steele January 2020: Rename the function format.articleno to
%%% format.articleno/eid to better reflect its behavior.
FUNCTION { format.articleno/eid }
{
articleno empty.or.unknown not eid empty.or.unknown not and
{ "Both articleno and eid are defined for " cite$ * warning$ }
'skip$
if$
articleno empty.or.unknown eid empty.or.unknown and
{ "" }
{
numpages empty.or.unknown
{ "articleno or eid field, but no numpages field, in "
cite$ * warning$ }
{ }
if$
eid empty.or.unknown
{ "Article \bibinfo{articleno}{" articleno * "}" * }
{ "Article \bibinfo{articleno}{" eid * "}" * }
if$
}
if$
}
FUNCTION { requires.check }
{ % Stack in: name1 name2 value1 value2
% Indicates that a nonempty value1 requires a nonempty value2.
% Warning if value2 is empty.or.unknown and value1 is not
empty.or.unknown swap$ empty.or.unknown not and
{ " is empty, for " * cite$ *
" is not empty but " swap$ * *
warning$
}
{ pop$ pop$ }
if$
}
FUNCTION { double.requires.check }
{ % Stack in: name1 name2 name3 value1 value2 value3
% Indicates that if value1 and value2 are both nonempty
% then value 3 must also be nonempty.
% Warning if value3 is empty.or.unknown and value1 and value2 are not
empty.or.unknown
swap$ empty.or.unknown not and
swap$ empty.or.unknown not and
{ " is empty, for " * cite$ *
" are not empty but " swap$ * *
" and " swap$ * *
warning$
}
{ pop$ pop$ pop$ }
if$
}
FUNCTION { format.given.np.day.month }
{
% Use "\ " between month and year because month may end with "."
"\ " swap$ joinsecond swap$ "date" * wrap.bibinfo
}
FUNCTION { format.given.np.day.month.year }
{
% Use "\ " between month and year because month may end with "."
"\ " swap$ join "\ " swap$ joinsecond swap$ "date" * wrap.bibinfo
}
FUNCTION { format.given.np.hour.minute.second.timezone }
{
duplicate$ #1 #1 substring$ duplicate$ duplicate$ "+" = swap$ "-" = or
{ swap$ #2 global.max$ substring$ swap$ "$" swap$ * "$" * swap$ * }
'pop$
if$
swap$ duplicate$ "" =
{ pop$ * }
{ swap$ * ":" swap$ joinfirst }
if$
":" swap$ joinfirst swap$ "time" * wrap.bibinfo
}
%%% Guy Steele January 2020: (almost) completely general date and time
% formatting that handles dates, times, timezones, and ranges.
FUNCTION { format.given.date.time.range }
{ % Arguments on stack are:
% ... nameprefix sepyear extrayear extramonth extraday
% year month day hour minute second timezone season
% endyear endmonth endday endhour endminute endsecond endtimezone endseason
% isrange
% If sepyear is true, the year has already been output, so take
% that into account.
'.isrange integer.parameter
'.endseason string.parameter
'.endtimezone string.parameter
'.endsecond string.parameter
'.endminute string.parameter
'.endhour string.parameter
'.endday string.parameter
'.endmonth string.parameter
'.endyear string.parameter
'.season string.parameter
'.timezone string.parameter
'.second string.parameter
'.minute string.parameter
'.hour string.parameter
'.day string.parameter
'.month string.parameter
'.year string.parameter
'.extraday string.parameter
'.extramonth string.parameter
'.extrayear string.parameter
'.sepyear integer.parameter
'.np string.parameter
.year empty.or.unknown
{ .extrayear '.year := }
'skip$
if$
.month empty.or.unknown
{ .extramonth '.month := }
'skip$
if$
.day empty.or.unknown
{ .extraday '.day := }
'skip$
if$
% A lot of tests to make sure the date info makes sense
.np "endyear" * .np "year" * .endyear .year requires.check
.np "endmonth" * .np "month" * .endmonth .month requires.check
.np "endday" * .np "day" * .endday .day requires.check
.np "endhour" * .np "hour" * .endhour .hour requires.check
.np "endminute" * .np "minute" * .endminute .minute requires.check
.np "endsecond" * .np "second" * .endsecond .second requires.check
.np "endtimezone" * .np "timezone" * .endtimezone .timezone requires.check
.np "endseason" * .np "season" * .endseason .season requires.check
.np "month" * .np "year" * .month .year requires.check
.np "day" * .np "month" * .day .month requires.check
.np "hour" * .np "day" * .hour .day requires.check
.np "minute" * .np "hour" * .minute .hour requires.check
.np "hour" * .np "minute" * .hour .minute requires.check
.np "second" * .np "minute" * .second .minute requires.check
.np "timezone" * .np "hour" * .timezone .hour requires.check
.np "endminute" * .np "endhour" * .endminute .endhour requires.check
.np "endhour" * .np "endminute" * .endhour .endminute requires.check
.np "endyear" * .np "month" * .np "endmonth" *
.endyear .month .endmonth double.requires.check
.np "endmonth" * .np "day" * .np "endday" *
.endmonth .day .endday double.requires.check
.np "endday" * .np "hour" * .np "endhour" *
.endday .hour .endhour double.requires.check
.np "endhour" * .np "minute" * .np "endminute" *
.endhour .minute .endminute double.requires.check
.np "endminute" * .np "second" * .np "endsecond" *
.endminute .second .endsecond double.requires.check
.day strip.leading.zero.digits '.day :=
.endday strip.leading.zero.digits '.endday :=
% Make ranges look better
.year .endyear =