#! /bin/sh

cat <<'END_OF_PREAMBLE'
.\" DO NOT EDIT THIS FILE.  IT WAS CREATED BY toc-make
.in 4
.nr PS 11
.nr VS 13
.ps 11
.vs 13
.LP
.sp 4
.\" .ce
.\" Appendix A
.sp 2
.ps +2
.ce
PISCES-II Input Specification
.ps -2
.sp 5
.tc .
.ta 2i 4i
.TS
center tab(~);
l c l.
.sp 2
END_OF_PREAMBLE

# =====================================================================
awk '{ list[$1] = $2	# only keep latest.
	}
  END {
	for (f in list)
		printf "%s %d\n", f, list[f]
	}' $* | sort +0 | awk '
  BEGIN {
	n = 0
	}
  {
	name = $1
	page = $2

	len = length(page)
	nz = 2*(4-len)
	zeros = substr("\\0\\0\\0\\0\\0\\0\\0\\0", 1, nz)
	new = zeros page

	pages[n  ] = new
	names[n++] = name
	}
  END {
	half = int((n+1)/2)
	for (i = 0; i < half; i++) {
		printf("%s \t%s", names[i], pages[i])
		j = i + half
		if (j < n) printf("~ ~%s \t%s\n", names[j], pages[j])
		else printf "\n"
		}
	}'

cat <<'END_OF_POST'
.TE
.tc 
.bp
END_OF_POST
