summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-09-24 16:02:10 +0000
committerKarl Berry <karl@freefriends.org>2011-09-24 16:02:10 +0000
commitc56636b114c0aa62facb8d8cff9a23af24c957ce (patch)
treedff5b73ee745f91b122446a87cd6588f7800eeef
parent54aaaeae8a91ae3f70ada46c5b4baf3430ded227 (diff)
do not output spurious \( when open range is re-opened
git-svn-id: svn://tug.org/texlive/trunk@24079 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Build/source/texk/makeindexk/ChangeLog6
-rw-r--r--Build/source/texk/makeindexk/Makefile.am4
-rw-r--r--Build/source/texk/makeindexk/Makefile.in102
-rw-r--r--Build/source/texk/makeindexk/genind.c8
-rw-r--r--Build/source/texk/makeindexk/tests/nested-range-bb.idx6
-rw-r--r--Build/source/texk/makeindexk/tests/nested-range-bb.tex72
-rwxr-xr-xBuild/source/texk/makeindexk/tests/nested-range-test.pl29
-rw-r--r--Build/source/texk/makeindexk/tests/nested-range.idx3
-rw-r--r--Build/source/texk/makeindexk/tests/nested-range.tex33
9 files changed, 258 insertions, 5 deletions
diff --git a/Build/source/texk/makeindexk/ChangeLog b/Build/source/texk/makeindexk/ChangeLog
index bd66325afb2..ced83f0984c 100644
--- a/Build/source/texk/makeindexk/ChangeLog
+++ b/Build/source/texk/makeindexk/ChangeLog
@@ -1,3 +1,9 @@
+2011-09-24 Karl Berry <karl@tug.org>
+
+ * genind.c (make_entry): do not output erroneous \( when
+ an open range is erroneously opened again. Report from
+ Barbara Beeton, see tests/nested-range-bb.tex and related.
+
2011-04-18 Peter Breitenlohner <peb@mppmu.mpg.de>
* sortid.c (compare_string): Cast strcoll() args to 'char *' to
diff --git a/Build/source/texk/makeindexk/Makefile.am b/Build/source/texk/makeindexk/Makefile.am
index 077e9706434..f48d38bbf20 100644
--- a/Build/source/texk/makeindexk/Makefile.am
+++ b/Build/source/texk/makeindexk/Makefile.am
@@ -1,6 +1,6 @@
## Makefile.am for the TeX Live subdirectory texk/makeindexk/
##
-## Copyright (C) 2009, 2010, 2011 Peter Breitenlohner <tex-live@tug.org>
+## Copyright (C) 2009-2011 Peter Breitenlohner <tex-live@tug.org>
## You may freely use, modify and/or distribute this file.
##
ACLOCAL_AMFLAGS = -I ../../m4
@@ -36,4 +36,6 @@ LDADD = $(KPATHSEA_LIBS)
dist_man1_MANS = makeindex.1 mkindex.1
+TESTS = tests/nested-range-test.pl
+
EXTRA_DIST = CONTRIB NOTES
diff --git a/Build/source/texk/makeindexk/Makefile.in b/Build/source/texk/makeindexk/Makefile.in
index cbbc70ddd5d..d1f6ec5b7bd 100644
--- a/Build/source/texk/makeindexk/Makefile.in
+++ b/Build/source/texk/makeindexk/Makefile.in
@@ -123,6 +123,8 @@ NROFF = nroff
MANS = $(dist_man1_MANS)
ETAGS = etags
CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
@@ -272,6 +274,7 @@ makeindex_SOURCES = \
LDADD = $(KPATHSEA_LIBS)
dist_man1_MANS = makeindex.1 mkindex.1
+TESTS = tests/nested-range-test.pl
EXTRA_DIST = CONTRIB NOTES
all: c-auto.h
$(MAKE) $(AM_MAKEFLAGS) all-am
@@ -539,6 +542,98 @@ GTAGS:
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
+ done; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
+ else \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
+ else \
+ skipped="($$skip tests were not run)"; \
+ fi; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes$$std"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
distdir: $(DISTFILES)
@list='$(MANS)'; if test -n "$$list"; then \
list=`for p in $$list; do \
@@ -700,6 +795,7 @@ distcleancheck: distclean
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(MANS) c-auto.h
installdirs:
@@ -807,10 +903,10 @@ uninstall-am: uninstall-binPROGRAMS uninstall-dist_binSCRIPTS \
uninstall-man: uninstall-man1
-.MAKE: all install-am install-strip
+.MAKE: all check-am install-am install-strip
-.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
- clean-binPROGRAMS clean-generic clean-libtool ctags dist \
+.PHONY: CTAGS GTAGS all all-am am--refresh check check-TESTS check-am \
+ clean clean-binPROGRAMS clean-generic clean-libtool ctags dist \
dist-all dist-bzip2 dist-gzip dist-lzma dist-shar dist-tarZ \
dist-xz dist-zip distcheck distclean distclean-compile \
distclean-generic distclean-hdr distclean-libtool \
diff --git a/Build/source/texk/makeindexk/genind.c b/Build/source/texk/makeindexk/genind.c
index 63def34dfbe..a17542b9bb6 100644
--- a/Build/source/texk/makeindexk/genind.c
+++ b/Build/source/texk/makeindexk/genind.c
@@ -126,8 +126,14 @@ make_entry(int n)
break;
if (level < FIELD_MAX)
new_entry();
- else
+
+ /* Repeat test from just below to see if we are already in an
+ open range. If so, we don't want to output anything. (It
+ ends up being output as an erroneous \(. See
+ tests/nested-range-bb.tex.) */
+ else if (! (*curr->encap == idx_ropen && in_range)) {
old_entry();
+ }
}
if (*curr->encap == idx_ropen)
diff --git a/Build/source/texk/makeindexk/tests/nested-range-bb.idx b/Build/source/texk/makeindexk/tests/nested-range-bb.idx
new file mode 100644
index 00000000000..6575c81ab54
--- /dev/null
+++ b/Build/source/texk/makeindexk/tests/nested-range-bb.idx
@@ -0,0 +1,6 @@
+\indexentry{random text|(}{1}
+\indexentry{periodic Hilbert transform|(}{1}
+\indexentry{periodic Hilbert transform|(}{2}
+\indexentry{random text|(}{2}
+\indexentry{periodic Hilbert transform|)}{2}
+\indexentry{random text|)}{2}
diff --git a/Build/source/texk/makeindexk/tests/nested-range-bb.tex b/Build/source/texk/makeindexk/tests/nested-range-bb.tex
new file mode 100644
index 00000000000..d2366dd6ccf
--- /dev/null
+++ b/Build/source/texk/makeindexk/tests/nested-range-bb.tex
@@ -0,0 +1,72 @@
+% Copyright 2011 Barbara Beeton <tex-live@tug.org>
+% You may freely use, modify and/or distribute this file.
+% This is the original annotated test report, with various extra info.
+% See below \end{document}.
+\documentclass{amsbook}
+\usepackage{verbatim}
+
+\makeindex
+
+\begin{document}
+
+\chapter{Demonstration of a Makeindex bug}
+
+\index{random text|(}%
+Here we open an index span for ``random text''.
+
+\index{periodic Hilbert transform|(}%
+How could we define the \emph{periodic Hilbert transform}?
+Here is an open index span for ``periodic Hilbert transform''.
+
+(lots more text omitted)
+\newpage
+
+We defined in Section~3 the
+\index{periodic Hilbert transform|(}%
+\emph{periodic Hilbert transform} or \emph{conjugate function}.
+A second open index span for ``periodic Hilbert transform''.
+
+\index{random text|(}%
+(more omitted text and a second open index span for ``random text'')
+
+Closing index spans for the two opened entries.
+\index{periodic Hilbert transform|)}%
+\index{random text|)}%
+
+\vspace{1\baselineskip}
+\verbatiminput{\jobname.tex}
+\newpage
+\noindent This is the .idx file from the previous run:
+\verbatiminput{\jobname.idx-prev}
+\vspace{2\baselineskip}
+This is the resulting .ilg file:
+\verbatiminput{\jobname.ilg}
+\vspace{2\baselineskip}
+And the resulting .ind file; note spurious \verb+\(+ inclusions.
+\verbatiminput{\jobname.ind}
+\end{document}
+
+
+Date: Thu, 22 Sep 2011 12:23:48 -0400
+From: Barbara Beeton
+Subject: a makeindex bug
+
+[...]
+
+to get the desired output, run latex, then makeindex.
+copy or rename <jobname>.idx to <jobname>.idx-prev,
+rerun latex, and take a look at the output. (the
+reason for the rename is that i've included in the
+output listings of the .idx(-prev), .ilg, and .ind
+files, all small, but very interesting.)
+
+the problem is that if a span is begun for a string
+and then a second span is begun for the same string
+without the first one being closed, the |( in the
+input is put into the output as \( -- with the
+result that an attempt to print the index will get
+an unmatched $ error. the unmatched span is noted
+in the .ilg file with a warning, but since most
+people ignore warnings the first time around (i
+certainly do), the unrecoverable (la)tex error in
+the index can really throw them into a tizzy.
diff --git a/Build/source/texk/makeindexk/tests/nested-range-test.pl b/Build/source/texk/makeindexk/tests/nested-range-test.pl
new file mode 100755
index 00000000000..b4882ce9d0e
--- /dev/null
+++ b/Build/source/texk/makeindexk/tests/nested-range-test.pl
@@ -0,0 +1,29 @@
+#!/usr/bin/env perl
+# $Id: bibtex-openout-test.pl 17384 2010-03-08 18:49:47Z karl $
+# Public domain. Originally written 2011, Karl Berry.
+# Check that makeindex doesn't create spurious output from nested ranges.
+# See nested-range.tex and -bb.tex.
+
+# srcdir = tetex (in the source tree)
+BEGIN { chomp ($srcdir = $ENV{"srcdir"} || `cd \`dirname $0\`/.. && pwd`); }
+require "$srcdir/../tests/common-test.pl";
+
+exit (&main ());
+
+sub main {
+ my $ret = &test_run ("makeindex", "$srcdir/tests/nested-range.idx",
+ "-o", "nested-range.ind",
+ "-t", "nested-range.ilg");
+
+ # The test fails if the output contains \(.
+ my $bad = 0;
+ local *IND;
+ $IND = "nested-range.ind";
+ open (IND) || die "open($IND) failed: $!";
+ while (<IND>) {
+ $bad = 1 if /\\\(/;
+ }
+ close (IND) || die "close($IND) failed: $!";
+
+ return $bad;
+}
diff --git a/Build/source/texk/makeindexk/tests/nested-range.idx b/Build/source/texk/makeindexk/tests/nested-range.idx
new file mode 100644
index 00000000000..a1154a3d5dc
--- /dev/null
+++ b/Build/source/texk/makeindexk/tests/nested-range.idx
@@ -0,0 +1,3 @@
+\indexentry{bad range|(}{1}
+\indexentry{bad range|(}{2}
+\indexentry{bad range|)}{2}
diff --git a/Build/source/texk/makeindexk/tests/nested-range.tex b/Build/source/texk/makeindexk/tests/nested-range.tex
new file mode 100644
index 00000000000..15be5e519a8
--- /dev/null
+++ b/Build/source/texk/makeindexk/tests/nested-range.tex
@@ -0,0 +1,33 @@
+% Copyright 2011 Barbara Beeton <tex-live@tug.org>
+% You may freely use, modify and/or distribute this file.
+%
+% This is the minimal version that reproduces the bug.
+% Some commented-out lines are some variations.
+% For all the details, see nested-range-bb.tex.
+%
+\documentclass{article}
+
+\makeindex
+
+\begin{document}
+\index{bad range|(}%
+%\index{ok range|(}%
+start.
+
+\newpage
+\index{bad range|(}%
+second page.
+
+\index{bad range|)}%
+%\index{ok range|)}%
+close.
+
+\end{document}
+
+\index{bad range|)}%
+second close.
+
+\index{bad range|)}%
+third close.
+
+\end{document}