#! /bin/sh -vx
# $Id: makeindex.test 78377 2026-03-15 10:25:56Z takuji $
# Copyright 2024-2026 TANAKA Takuji <ttk@t-lab.opal.ne.jp>
# Copyright 2017 Karl Berry <tex-live@tug.org>
# Copyright 2012 Peter Breitenlohner <tex-live@tug.org>
# You may freely use, modify and/or distribute this file.

BinDir=${BinDir:-.}
ExeExt=${ExeExt:-}
_makeindex=$BinDir/makeindex$ExeExt

TEXMFCNF=$srcdir/../kpathsea
export TEXMFCNF

rm -f sample.* foo.* tort*.*
rc=0

$_makeindex $srcdir/tests/sample.idx -o sample.ind1 -t sample.ilg1 \
	&& diff $srcdir/tests/sample.ind sample.ind1 || rc=1

cat $srcdir/tests/sample.idx | $_makeindex >sample.ind2 2>sample.ilg2 \
	&& diff $srcdir/tests/sample.ind sample.ind2 || rc=2

$_makeindex $srcdir/tests/foo.idx -o foo.ind1 -t foo.ilg1 \
	&& diff $srcdir/tests/foo.ind foo.ind1 || rc=11

cat $srcdir/tests/foo.idx | $_makeindex >foo.ind2 2>foo.ilg2 \
	&& diff $srcdir/tests/foo.ind foo.ind2 || rc=12

$_makeindex $srcdir/tests/foo.idx -s $srcdir/tests/head1.ist -o foo.ind3 -t foo.ilg3 \
	&& diff $srcdir/tests/foo1.ind foo.ind3 || rc=13

$_makeindex $srcdir/tests/foo.idx -s $srcdir/tests/head2.ist -o foo.ind4 -t foo.ilg4 \
	&& diff $srcdir/tests/foo1.ind foo.ind4 || rc=14

$_makeindex $srcdir/tests/tort.idx -o tort.ind1 -t tort.ilg1 \
	&& diff $srcdir/tests/ok-tort.ind tort.ind1 || rc=20

$_makeindex $srcdir/tests/tortW.idx -o tortW.ind1 -t tortW.ilg1 \
	&& diff $srcdir/tests/ok-tort.ind tortW.ind1 || rc=21

$_makeindex $srcdir/tests/tort.idx -s $srcdir/tests/head1.ist -o tort2.ind1 -t tort2.ilg1 \
	&& diff $srcdir/tests/ok-tort2.ind tort2.ind1 || rc=22

$_makeindex $srcdir/tests/tortW.idx -s $srcdir/tests/head1.ist -o tortW2.ind1 -t tortW2.ilg1 \
	&& diff $srcdir/tests/ok-tort2.ind tortW2.ind1 || rc=23


exit $rc
