pdbain@wateng.UUCP (Peter Bain) (06/19/85)
The following awk(1) script will do a rough-and-ready formatting job on referneces which are in refer(1) format (refer format has most lines starting with a % and a key character). Just save the script in a file and pipe the refer file into the script as follows: cat <refer file> | awk -f <awkscript file> ---------------------- cut here ------------------------------------ /^%/ { prevfield = curfield curfield = substr($0,2,1) if (curfield == "m") curfield = "M" if (fields[curfield]) fields[curfield] = fields[curfield] ", " substr($0,4) else fields[curfield] = substr($0,4) } /^[^%]/ { fields[curfield] = fields[curfield] "\n" $0 } /^$/ { doc = "" if (fields["A"]) { doc = doc fields["A"] if (fields["l"] ~ /edited.*/ && !fields["E"]) if (fields["e"]) doc = doc "(eds.)" else doc = doc "(ed.)" doc = doc "," } if (fields["T"]) if (fields["B"] || fields["J"]) { if (length(doc fields["T"]) > 73) { print doc doc = "" } doc = doc "\"" fields["T"] "\", " } else { if (length(doc fields["T"]) > 73) { print doc doc = "" } doc = doc fields["T"] ", " } if (fields["J"]) { if (length(doc fields["J"]) > 73) { print doc doc = "" } doc = doc fields["J"] ", " if (fields["V"] ) { if (fields["N"]) { volno = fields["V"] "(" fields["N"] ")" if (length(doc volno) > 73) { print doc doc = "" } } else volno = "vol. " fields["V"] doc = doc volno ", " volno = "" } } if (fields["M"]) date = fields["M"] if (fields["D"]) date = date " "fields["D"] if (date) { if (length(doc date) > 73) { print doc doc = "" } doc = doc date ", " date = "" } if (fields["E"]) { if (length(doc fields["E"]) > 73) { print doc doc = "" } doc = doc fields["E"] if (fields["e"]) doc = doc "(eds.)" doc = doc ", " } if (fields["l"] == "dissertation") { if (fields["Q"]) { level = fields["Q"] " dissertation," if (length(doc level) >73) { print doc doc = "" } doc = doc level } } if (fields["I"]) { if (length(doc fields["I"]) >73) { print doc doc = "" } doc = doc fields["I"] ", " } if (fields["S"]) { if (length(doc fields["S"]) >73) { print doc doc = "" } doc = doc fields["S"] ", " } if (fields["C"]) { if (length(doc fields["C"]) >73) { print doc doc = "" } doc = doc fields["C"] ", " } if (fields["P"]) { if (length(doc fields["P"]) >73) { print doc doc = "" } doc = doc fields["P"] ", " } print doc "\n" for (i in fields) fields[i] = "" } -- - peter bain ...!{allegra|decvax|clyde|ihnp4 }!watmath!wateng!pdbain hard mail: CCNG, CPH-2369A, University of Waterloo, Waterloo, Ont. Canada N2M 5G4 telephone: (519) 885-1211 x2810