### rcshist.awk -- Generate an html log with diffs from RCS # Author: Florian Guthmann # Maintainer: Philip Kaludercic # Version: $Id: rcshist.awk,v 1.20 2024/05/16 07:15:20 oj14ozun Exp $ # URL: https://wwwcip.cs.fau.de/~oj14ozun/src+etc/rcshist.awk ### Commentary # For a RCS versioned FILE, generate HTML output using this command # pattern: # # $ rlog FILE | awk -f rcshist.awk # # Optionally pass a "-v CSS=[some url here]" flag to awk if you want # to use a specific stylesheet. # # This script is a fork of Florian's non-POSIX/Kernighan compliant # version https://wwwcip.cs.fau.de/~oc45ujef/misc/src/rcshist.awk. ### Code function xml(tag, content, attr) { printf("<%s", tag) for (key in attr) { printf(" %s=\"%s\"", key, attr[key]) } if (!content) printf("/> ") else { # https://www.w3.org/TR/xml/#dt-escape gsub(/&/, "\\&", content) gsub(/>/, "\\>", content) gsub(/%s", content, tag) } } function diff(r1, r2) { cmd = "rcsdiff -du -b -r" r1 " -r" r2 " " file while ((cmd | getline output) > 0){ if (output ~ /^\-/) { xml("del", output) } else if (output ~ /^\+/) { xml("ins", output) } else { xml("code", output) } printf("\n") } close(cmd) } function fix_date(date) { split("", date_parts) split(date, date_parts, "/") return date_parts[1] "-" date_parts[2] "-" date_parts[3] } function diff_to_html(rev) { printf("
", "rev" revs[rev]) link["href"] = "#rev" revs[rev] split(messages[rev - 1], lines, /\034/) cmsg["class"] = "cmsg" print "" xml("time", fix_date(dates[rev - 1])) xml("a", revs[rev], link) printf(" ") xml("span", lines[1], cmsg) print "" if (length(lines[2]) > 1) { xml("p", lines[2]) } print "
"
    diff(revs[rev], revs[rev - 1])
    print "
" print "
" } /^Working file/ { file = $3 xml("title", "Revision-History of the File " file) print "" print "" xml("h1", "Revision-History of the File " file) rev_i = 0 } /^revision/ { revs[++rev_i] = $2 getline metadata getline message sub(/^Summary: */, "", message) message = message "\034" while ((getline line) > 0 && !(line ~ /^-+$/)) { message = message "\n" line } messages[rev_i] = message split(metadata, a, " ") dates[rev_i] = a[2] " " a[3] sub(/;$/, "", dates[rev_i]) if (rev_i > 1) { diff_to_html(rev_i) } } BEGIN { print "" print "" print "" print "" print "" if (CSS) { print "" } print "" } END { print "
" print "" # pretty disgusting, I have to say print "" print "" print "" }