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
|
#!/usr/bin/awk -f
# $Id: pkg1,v 1.5 2003/02/22 10:56:33 herbert Exp $
function read(err) {
err = getline < overf
if (err < 0) {
print "getline failed on " overf > "/dev/stderr"
exit 1
} else if (err == 0) {
eof = 1
return
}
opkg = $1
oprio = $2 != "-" ? $2 : ""
osect = $3 != "-" ? $3 : ""
if (NF >= 5) {
otask = $4 != "-" ? $4 : ""
}
}
BEGIN {
overf = ARGV[1]
contents = ARGV[2]
ARGC = 1
read()
}
{
pkg = $1
file = $2
while (!eof && opkg < pkg) {
read()
}
task = sect = prio = ""
if (!eof && opkg == pkg) {
prio = oprio
sect = osect
task = otask
}
while ((err = getline < file) > 0) {
if (/^Section:/) {
if (sect != "") {
print "Section: " sect
} else {
print
sect = substr($0, 8)
gsub(/ */, "", sect)
}
continue
}
if (prio != "" && /^Priority:/) {
print "Priority: " prio
continue
}
if (task != "" && /^$/) {
print "Task: " task
}
print
}
if (err < 0) {
print "getline failed on " file > "/dev/stderr"
exit 1
}
close(file)
}
contents {
cnt = split(file, a, "/")
file = substr(file, 1, length(file) - length(a[cnt]) - 8)
file = file "/.content/" a[cnt]
while (getline < file > 0) {
print $0 " " sect "/" pkg > contents
}
close(file)
}
|