xref: /netbsd-src/external/gpl2/texinfo/dist/util/tex3patch (revision 29619d2afe564e54d657b83e5a3ae89584f83720)
1*29619d2aSchristos#!/bin/sh
2*29619d2aSchristos# Auxiliary script to work around TeX 3.0 bug.      ---- tex3patch  ----
3*29619d2aSchristos# patches texinfo.tex in current directory, or in directory given as arg.
4*29619d2aSchristos
5*29619d2aSchristosANYVERSION=no
6*29619d2aSchristos
7*29619d2aSchristosfor arg in $1 $2
8*29619d2aSchristosdo
9*29619d2aSchristos	case $arg in
10*29619d2aSchristos		--dammit | -d ) ANYVERSION=yes ;;
11*29619d2aSchristos
12*29619d2aSchristos		* ) dir=$arg
13*29619d2aSchristos	esac
14*29619d2aSchristosdone
15*29619d2aSchristos
16*29619d2aSchristosif [ -z "$dir" ]; then
17*29619d2aSchristos  dir='.'
18*29619d2aSchristosfi
19*29619d2aSchristos
20*29619d2aSchristosif [ 2 -lt $# ] || [ ! -f "$dir/texinfo.tex" ]; then
21*29619d2aSchristos  echo "To patch texinfo.tex for peaceful coexistence with Unix TeX 3.0,"
22*29619d2aSchristos  echo "run    $0"
23*29619d2aSchristos  echo "with no arguments in the same directory as texinfo.tex; or run"
24*29619d2aSchristos  echo "       $0 DIRECTORY"
25*29619d2aSchristos  echo "(where DIRECTORY is a path leading to texinfo.tex)."
26*29619d2aSchristos  exit
27*29619d2aSchristosfi
28*29619d2aSchristos
29*29619d2aSchristosif [ -z "$TMPDIR" ]; then
30*29619d2aSchristos  TMPDIR=/tmp
31*29619d2aSchristosfi
32*29619d2aSchristos
33*29619d2aSchristosecho "Checking for \`dummy.tfm'"
34*29619d2aSchristos
35*29619d2aSchristos( cd $TMPDIR; tex '\relax \batchmode \font\foo=dummy \bye' )
36*29619d2aSchristos
37*29619d2aSchristosgrep -s '3.0' $TMPDIR/texput.log
38*29619d2aSchristosif [ 1 = "$?" ] && [ "$ANYVERSION" != "yes" ]; then
39*29619d2aSchristos	echo "You probably do not need this patch,"
40*29619d2aSchristos        echo "since your TeX does not seem to be version 3.0."
41*29619d2aSchristos	echo "If you insist on applying the patch, run $0"
42*29619d2aSchristos	echo "again with the option \`--dammit'"
43*29619d2aSchristos	exit
44*29619d2aSchristosfi
45*29619d2aSchristos
46*29619d2aSchristosgrep -s 'file not found' $TMPDIR/texput.log
47*29619d2aSchristosif [ 0 = $? ]; then
48*29619d2aSchristos	echo "This patch requires the dummy font metric file \`dummy.tfm',"
49*29619d2aSchristos	echo "which does not seem to be part of your TeX installation."
50*29619d2aSchristos	echo "Please get your TeX maintainer to install \`dummy.tfm',"
51*29619d2aSchristos	echo "then run this script again."
52*29619d2aSchristos	exit
53*29619d2aSchristosfi
54*29619d2aSchristosrm $TMPDIR/texput.log
55*29619d2aSchristos
56*29619d2aSchristosecho "Patching $dir/texinfo.tex"
57*29619d2aSchristos
58*29619d2aSchristossed -e 's/%%*\\font\\nullfont/\\font\\nullfont/' \
59*29619d2aSchristos    $dir/texinfo.tex >$TMPDIR/texinfo.tex
60*29619d2aSchristosmv $dir/texinfo.tex $dir/texinfo.tex-distrib; mv $TMPDIR/texinfo.tex $dir
61*29619d2aSchristos
62*29619d2aSchristosif [ 0 = $? ]; then
63*29619d2aSchristos	echo "Patched $dir/texinfo.tex to avoid TeX 3.0 bug."
64*29619d2aSchristos	echo "The original version is saved as $dir/texinfo.tex-distrib."
65*29619d2aSchristoselse
66*29619d2aSchristos	echo "Patch failed.  Sorry."
67*29619d2aSchristosfi
68*29619d2aSchristos----------------------------------------tex3patch ends
69*29619d2aSchristos
70*29619d2aSchristos
71