aboutsummaryrefslogtreecommitdiff
path: root/toc
diff options
context:
space:
mode:
Diffstat (limited to 'toc')
-rw-r--r--toc/Makefile5
-rwxr-xr-xtoc/gtoc (renamed from toc/groc)2
-rwxr-xr-xtoc/toc31
-rwxr-xr-xtoc/troc17
4 files changed, 36 insertions, 19 deletions
diff --git a/toc/Makefile b/toc/Makefile
index 6cf0b74..3211efd 100644
--- a/toc/Makefile
+++ b/toc/Makefile
@@ -1,2 +1,5 @@
+README.pdf: README.t
+ ./gtoc -Tps README.t | ps2pdf - > README.pdf
+
example.pdf: example.t
- ./groc -Tps example.t | ps2pdf - > example.pdf
+ ./gtoc -Tps example.t | ps2pdf - > example.pdf
diff --git a/toc/groc b/toc/gtoc
index 80a65a2..f64ddbe 100755
--- a/toc/groc
+++ b/toc/gtoc
@@ -1,4 +1,4 @@
#!/bin/sh
export TROFF=groff
-exec=${0%groc}troc
+exec=${0%gtoc}toc
exec "$exec" "$@"
diff --git a/toc/toc b/toc/toc
new file mode 100755
index 0000000..2b21790
--- /dev/null
+++ b/toc/toc
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# toc -- run troff in three passes
+
+: ${TROFF:=troff}
+
+if [ ! -t 0 ]; then
+ f=`mktemp`
+ cat > $f
+ set -- "$@" $f
+fi
+
+if [ -z "$PIPE" ]; then
+ g=`mktemp`
+ h=`mktemp`
+
+ 2>$g >/dev/null $TROFF -rte=1 -rto=0 -E "$@"
+ <$g 2>$h >/dev/null $TROFF -rte=1 -rto=1 -E "$@"
+ <$h $TROFF -rte=0 -rto=1 "$@"
+ s=$?
+
+ rm $h $g
+else
+ $TROFF -rte=1 -rto=0 -zE "$@" 2>&1 |
+ $TROFF -rte=1 -rto=1 -zE "$@" 2>&1 |
+ $TROFF -rte=0 -rto=1 "$@"
+ s=$?
+fi
+
+[ ! -t 0 ] && rm $f
+exit $s
diff --git a/toc/troc b/toc/troc
deleted file mode 100755
index 8577531..0000000
--- a/toc/troc
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-: ${TROFF:=troff}
-
-if [ ! -t 0 ]; then
- f=`mktemp`
- cat > "$f"
- set -- "$@" "$f"
-fi
-
-"$TROFF" -rte=1 -rto=0 -zE "$@" 2>&1 |
-"$TROFF" -rte=1 -rto=1 -zE "$@" 2>&1 |
-"$TROFF" -rte=0 -rto=1 "$@"
-s=$?
-
-[ ! -t 0 ] && rm "$f"
-exit $s