blob: 3ebd16f261b481bdfe9484912c60c3dcb2ae39df (
plain)
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
|
# bib-select.awk - emit entries selected by key, canonically
#
# Requires bib-parse.awk and bib-canon.awk. Variables (set with -v):
# keys - comma-separated list of entry keys; a key of "*" selects
# every entry (as produced by \nocite{*})
# keyfile - file with one key per line, for key lists too large to
# pass on the command line; merged with keys
# invert - 0: emit entries whose key is in the list
# 1: emit entries whose key is NOT in the list
#
# With no keys and invert=1 this acts as a canonicalizing filter for
# everything. @string and @preamble blocks always pass through.
function bib_sel_add(k) {
if (k == "*")
BIB_SEL_ALL = 1
else
BIB_SEL[k] = 1
}
BEGIN {
bib_sel_n = split(keys, bib_sel_k, ",")
for (bib_sel_i = 1; bib_sel_i <= bib_sel_n; bib_sel_i++)
bib_sel_add(bib_sel_k[bib_sel_i])
if (keyfile != "") {
while ((getline bib_sel_line < keyfile) > 0)
bib_sel_add(bib_sel_line)
close(keyfile)
}
}
function bib_pass(raw) {
bib_sep()
print raw
}
function bib_entry(type, key) {
if (BIB_SEL_ALL || (key in BIB_SEL) != invert + 0) {
bib_sep()
bib_emit(type, key)
}
}
|