diff options
| author | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2026-06-06 13:44:00 -0400 |
|---|---|---|
| committer | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2026-06-06 13:44:00 -0400 |
| commit | c102ab995f9a86a77e40b9a952b2b23c0bd7de74 (patch) | |
| tree | d51b9a8f1a55f7f6e6e5afb89d524b9baa350f45 /lib/bib-select.awk | |
| parent | b56c273d8198ae6cee69bbc9fe5a6a61da4074e4 (diff) | |
| download | bibutils-c102ab995f9a86a77e40b9a952b2b23c0bd7de74.tar.gz | |
Fuzzing with associated fixes
Diffstat (limited to 'lib/bib-select.awk')
| -rw-r--r-- | lib/bib-select.awk | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/bib-select.awk b/lib/bib-select.awk index 9aa5a37..3ebd16f 100644 --- a/lib/bib-select.awk +++ b/lib/bib-select.awk @@ -1,21 +1,31 @@ # 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{*}) -# invert - 0: emit entries whose key is in the list -# 1: emit entries whose key is NOT in the list +# 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 keys="" and invert=1 this acts as a canonicalizing filter for +# 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++) { - if (bib_sel_k[bib_sel_i] == "*") - BIB_SEL_ALL = 1 - else - BIB_SEL[bib_sel_k[bib_sel_i]] = 1 + 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) } } |