Debian Codegraph @

texmf-dist/source/bibtex/bibtools/looktex.awk

raw
1 # looktex.awk
2 #
3 # Goes with bin/looktex - look for a keyword in the references in a BiBTeX file
4 #
5 # David Kotz ([email protected])
6 #
7 # This takes a list of line numbers that had the keyword. Some of the
8 # line numbers will be followed by "entry" or "entry key"; "entry"
9 # means that the line number is the start of a new bibtex entry, not a
10 # line containing the keyword. "entry key" means that it is a line
11 # starting an entry AND containing the keyword.
12 #
13 # On stdout, we produce a sed script for printing entries that had a
14 # match in them somewhere. This is a list of lines like "A,Bp" where A
15 # and B are line numbers.
16
17 BEGIN {found=0; last=1}
18
19 # defines the start of a new entry WITH a keyword match
20 NF==3 {
21 if (found) { print last "," $1-1 "p" }
22 found=1
23 last=$1
24 }
25
26 # defines the start of a new entry
27 NF==2 {
28 if (found) { print last "," $1-1 "p" }
29 found=0
30 last=$1
31 }
32
33 # marks a place where the keyword was found
34 NF==1 {found=1}
35
36 END {
37 if (found)
38 print last ",$p";
39 }