17ae17deuqs#!/bin/sh
2bb683e4bapt# Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
37ae17deuqs#
47ae17deuqs# Permission to use, copy, modify, and distribute this software for any
57ae17deuqs# purpose with or without fee is hereby granted, provided that the above
67ae17deuqs# copyright notice and this permission notice appear in all copies.
77ae17deuqs#
87ae17deuqs# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
97ae17deuqs# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
107ae17deuqs# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
117ae17deuqs# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
127ae17deuqs# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
137ae17deuqs# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
147ae17deuqs# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
157ae17deuqs
167ae17deuqsif [ `id -u` -eq 0 ]; then
177ae17deuqs  echo "$0: do not run me as root"
187ae17deuqs  exit 1
197ae17deuqsfi
207ae17deuqs
217ae17deuqsif [ $# -eq 0 ]; then
22bb683e4bapt  echo "usage: $0 [-h|-u] manual_source_file ..."
237ae17deuqs  exit 1
247ae17deuqsfi
257ae17deuqs
26ecbd8afbaptif [ "X$1" = "X-h" ]; then
27ecbd8afbapt  shift
28ecbd8afbapt  export PATH="/usr/local/heirloom-doctools/bin:$PATH"
29ecbd8afbapt  EQN="neqn"
30ecbd8afbapt  ROFF="nroff"
31bb683e4bapt  MOPT="-Ios=BSD -Tascii $MOPT"
32bb683e4bapt  COLPIPE="col -b"
3346b1dcfbaptelif [ "X$1" = "X-u" ]; then
3446b1dcfbapt  shift
3546b1dcfbapt  ROFF="groff -ket -ww -Tutf8 -P -c"
36bb683e4bapt  MOPT="-Ios=OpenBSD -Wall -Tutf8 $MOPT"
37bb683e4bapt  COLPIPE="cat"
38ecbd8afbaptelse
3972da6efbapt  ROFF="groff -ket -ww -mtty-char -Tascii -P -c"
40bb683e4bapt  MOPT="-Ios=OpenBSD -Wall -Tascii $MOPT"
41bb683e4bapt  COLPIPE="cat"
42ecbd8afbaptfi
43ecbd8afbapt
447ae17deuqswhile [ -n "$1" ]; do
457ae17deuqs  file=$1
467ae17deuqs  shift
477ae17deuqs  echo " ========== $file ========== "
48bb683e4bapt  $ROFF -mandoc $file | $COLPIPE 2> /tmp/roff.err > /tmp/roff.out
49bb683e4bapt  ${MANDOC:=mandoc} $MOPT $file | $COLPIPE \
50877b18fbapt    2> /tmp/mandoc.err > /tmp/mandoc.out
51ecbd8afbapt  for i in roff mandoc; do
5246b1dcfbapt    [ -s /tmp/$i.err ] && echo "$i errors:" && cat /tmp/$i.err
53eb03421bapt  done
5472da6efbapt  diff -au $DIFFOPT /tmp/roff.out /tmp/mandoc.out 2>&1
557ae17deuqsdone
567ae17deuqs
577ae17deuqsexit 0
58