From 6711a42d6175984a029e7af7a4886ed44c998e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 23 Jun 2021 12:02:47 +0200 Subject: toc: Add (toc) prefix to .te output The original troff cannot disable error output. This patch disambiguates .te's output from troff's normal errors. The (toc) prefix is removed by sed in the toc script. --- toc/toc | 38 ++++++++++++++++++++------------------ toc/toc.tmac | 2 +- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/toc/toc b/toc/toc index 2b21790..9544934 100755 --- a/toc/toc +++ b/toc/toc @@ -3,29 +3,31 @@ # toc -- run troff in three passes : ${TROFF:=troff} +SED='sed -n /^(toc)/{s///;p}' +RM=rm + +trap '$RM; RM=; exit 130' INT +trap '$RM' EXIT + +tmp() { + x=`mktemp` || exit $? + RM=$RM\ $x + eval $1=\$x +} if [ ! -t 0 ]; then - f=`mktemp` + tmp f 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 +tmp g +tmp h + +$TROFF -rte=1 -rto=0 "$@" 2>&1 1>/dev/null | $SED >$g +$TROFF -rte=1 -rto=1 "$@" <$g 2>&1 1>/dev/null | $SED >$h +$TROFF -rte=0 -rto=1 "$@" <$h + +s=$? -[ ! -t 0 ] && rm $f exit $s diff --git a/toc/toc.tmac b/toc/toc.tmac index 143994e..8431e06 100644 --- a/toc/toc.tmac +++ b/toc/toc.tmac @@ -15,7 +15,7 @@ . .\" te -- collect line .de te -. if \n(te=1 .tm \$* +. if \n(te=1 .tm (toc)\$* .. . .ec -- cgit v1.2.3