chiark / gitweb /
Build system overhaul to conform to new standards.
[tripe] / server / make-summary
diff --git a/server/make-summary b/server/make-summary
new file mode 100755 (executable)
index 0000000..2aff34c
--- /dev/null
@@ -0,0 +1,29 @@
+#! /usr/bin/awk -f
+
+BEGIN { n = 0; opts = 0; sep = 0; }
+
+/^\.\\\"\* ([0-9]+) (.*)$/ {
+  n = $2;
+  name = $3;
+  for (i = 4; i <= NF; i++) name = name " " $i;
+  head[n] = name;
+}
+/^\.\\\"\+opts$/ { opts = 1; lines[n] = lines[n] "\\h'2n'Options:\n.RS\n"; }
+/^\.\\\"\-opts$/ { opts = 0; lines[n] = lines[n] ".RE\n"; }
+/^\.\\\"\+sep$/ { sep = 1; }
+/^\.\\\"\-sep$/ { sep = 0; }
+/^\.\\\"\-opts$/ { opts = 0; lines[n] = lines[n] ".RE\n"; }
+/^\.SP/ { print; getline; lines[n] = lines[n] $0 "\n"; }
+/^\.TP/ { if (opts) { print; getline; lines[n] = lines[n] $0 "\n"; } }
+/^\.SS/ { if (sep) lines[n] = lines[n] ".PP\n"; }
+
+{ print; }
+
+/^\.\\\"= summary/ {
+  for (i = 0; i < 100; i++) {
+    if (!(i in head)) continue;
+    print ".SS \"" head[i] "\"";
+    print ".nf";
+    print lines[i] ".fi";
+  }
+}