Log changes
[latex2e.git] / latex2e-20151001 / scripts / checktlg
blobd8e88dcbdea525b63cdf261879366064ffce5c02
1 #!/bin/sh
3 # This file is part of the validate package.
4 # ------------------------------------------
6 # Checks a .tlg file against the .log file created by TeX from the test
7 # file.
8 # A test file must have the extension .lvt
9 # Runs tex two times
11 # usage: checktlg <fmt name> <test file base> [translation table]
14 # check number of args and set format etc.
16 if [ $# -lt 2 -o $# -gt 3 ] ; then
17 echo >&2 Usage: checktlg format file [translation_table]
18 exit 1
21 TRANSLATE=""
22 if [ $# = 3 ]
23 then
24 TRANSLATE="--translate-file=$3"
26 LATEX="etex $TRANSLATE -efmt=`dirname $1`/`basename $1 .fmt`"
27 BASE=`basename $2 .lvt`
28 BASEDIR=`dirname $2`
30 LANG=C ; export LANG
32 TLG_BASE=$BASE
34 # remove all kind of rubbish
36 rm -f $BASE.log $BASE.au? $BASE.tmp.tlg $TLG_BASE.tlg.diff $BASE.dvi
37 rm -f $BASE.lvt.log $BASE.lvt.au? $BASE.lvt.dvi $TLG_BASE.mod.tlg
38 rm -f $BASE.glo $BASE.idx $BASE.lof $BASE.toc $BASE.lot
39 rm -f $BASE.lvt.glo $BASE.lvt.idx $BASE.lvt.lof $BASE.lvt.toc $BASE.lvt.lot
41 #echo ' '
42 echo -n Checking $BASE...
43 # run TeX twice with chosen format
45 #$LATEX $BASE.lvt
46 ( yes "" | $LATEX $BASE.lvt > /dev/null 2>&1 ) 2>/dev/null
47 ( yes "" | $LATEX $BASE.lvt > /dev/null 2>&1 ) 2>/dev/null
49 if test -r $BASE.lvt.log ; then LOG=$BASE.lvt.log ; else LOG=$BASE.log ; fi
51 # remove stuff from the log which is of no interest and save the result
52 # in tmp file
54 #sed -e "1,/START-TEST-LOG/d" \
55 # -e "/END-TEST-LOG/,//d" \
56 # -e "/OMIT/,/TIMO/d" \
57 # -e "s/$BASE//" \
58 # ${BEFORE_SED_SCRIPTS} \
59 # -e "/([^ ]*fd/,/^[ ]*)/d" \
60 # -e "\![^<][0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]!d" \
61 # ${AFTER_SED_SCRIPTS} \
62 # $LOG > $BASE.tmp.tlg
63 perl `dirname $0`/log2tlg $BASE < $LOG > $BASE.tmp.tlg
65 # remove empty lines from .tlg file
66 perl -n -e '/^\s*$/ || print' < $TLG_BASE.tlg >$TLG_BASE.mod.tlg
68 # compare both files
70 ##if (cmp -s $TLG_BASE.mod.tlg $BASE.tmp.tlg)
72 # use diff to allow stripping of trailing CR when using across Windows + Unix
74 if (diff -q --strip-trailing-cr $TLG_BASE.mod.tlg $BASE.tmp.tlg)
75 then
76 # echo Check passed for $BASE
77 echo ' PASSED'
78 rm -f $BASE.log $BASE.au? $BASE.tmp.tlg $TLG_BASE.tlg.diff $BASE.dvi
79 rm -f $BASE.glo $BASE.idx $BASE.lof $BASE.toc $BASE.lot $TLG_BASE.mod.tlg
80 else
81 # echo ' '
82 # echo '***************************************************************'
83 # echo '*' Check not passed! Preparing context diff in $TLG_BASE.tlg.diff
84 # echo '***************************************************************'
85 # echo done with $TLG_BASE.tlg.diff
86 echo ' ***** NOT PASSED ***** see:' $TLG_BASE.tlg.diff
88 # strip CR in comparison
89 diff --strip-trailing-cr -c $TLG_BASE.mod.tlg $BASE.tmp.tlg > $TLG_BASE.tlg.diff