summaryrefslogtreecommitdiff
path: root/Build/source/texk/makeindexk
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2012-07-27 07:27:29 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2012-07-27 07:27:29 +0000
commitb8d362466a8e4c679b09c8044f85073655bd7ff4 (patch)
treeaf6cc69d21cd49bbcfb8c326128740363a2ba293 /Build/source/texk/makeindexk
parentc5709ea5924966b82883b45f0b92e7d6a0486226 (diff)
makeindexk: Use binary mode for input and output (from W32TeX)
Add a new file with the qqsort() prototype Add a new test case git-svn-id: svn://tug.org/texlive/trunk@27192 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/makeindexk')
-rw-r--r--Build/source/texk/makeindexk/ChangeLog15
-rw-r--r--Build/source/texk/makeindexk/Makefile.am8
-rw-r--r--Build/source/texk/makeindexk/Makefile.in7
-rw-r--r--Build/source/texk/makeindexk/mkind.c8
-rw-r--r--Build/source/texk/makeindexk/mkind.h9
-rw-r--r--Build/source/texk/makeindexk/qsort.c3
-rw-r--r--Build/source/texk/makeindexk/qsort.h12
-rw-r--r--Build/source/texk/makeindexk/sortid.c3
-rwxr-xr-xBuild/source/texk/makeindexk/tests/makeindex.test16
-rw-r--r--Build/source/texk/makeindexk/tests/sample.idx15
-rw-r--r--Build/source/texk/makeindexk/tests/sample.ind15
11 files changed, 96 insertions, 15 deletions
diff --git a/Build/source/texk/makeindexk/ChangeLog b/Build/source/texk/makeindexk/ChangeLog
index 64bbcb621a2..30061dae1db 100644
--- a/Build/source/texk/makeindexk/ChangeLog
+++ b/Build/source/texk/makeindexk/ChangeLog
@@ -1,3 +1,18 @@
+2012-07-26 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * mkind.[ch] [WIN32]: Use binary mode for input and output
+ (from W32TeX).
+ * mkind.h: Drop extern declaration of qqsort() and main().
+ * qsort.h (new): Extern declaration of of qqsort().
+ * qsort.c: Replace #include "mkind.h" by #include "qsort.h".
+ * sortid.c: Add #include "qsort.h".
+ * Makefile.am (makeindex_SOURCES): Add the new file qsort.h.
+
+ * tests/makeindex.test (new): Shell script for a test case.
+ * tests/sample.idx (new): Test input.
+ * tests/sample.ind (new): Expected output.
+ * Makefile.am: Adapted.
+
2012-07-15 Peter Breitenlohner <peb@mppmu.mpg.de>
* mkind.c: Pass program name string to kpse_set_program_name.
diff --git a/Build/source/texk/makeindexk/Makefile.am b/Build/source/texk/makeindexk/Makefile.am
index 04767149ab0..a621eb2d3c9 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-2011 Peter Breitenlohner <tex-live@tug.org>
+## Copyright (C) 2009-2012 Peter Breitenlohner <tex-live@tug.org>
## You may freely use, modify and/or distribute this file.
##
ACLOCAL_AMFLAGS = -I ../../m4
@@ -21,6 +21,7 @@ makeindex_SOURCES = \
mkind.c \
mkind.h \
qsort.c \
+ qsort.h \
scanid.c \
scanid.h \
scanst.c \
@@ -40,11 +41,14 @@ EXTRA_DIST = CONTRIB NOTES
## Tests
##
-TESTS = tests/nested-range-test.pl
+TESTS = tests/nested-range-test.pl tests/makeindex.test
EXTRA_DIST += $(TESTS)
## tests/nested-range-test.pl
EXTRA_DIST += tests/nested-range.tex tests/nested-range.idx \
tests/nested-range-bb.tex tests/nested-range-bb.idx
DISTCLEANFILES = nested-range.ilg nested-range.ind
+## tests/makeindex.test
+EXTRA_DIST += tests/sample.idx tests/sample.ind
+DISTCLEANFILES += sample.*
diff --git a/Build/source/texk/makeindexk/Makefile.in b/Build/source/texk/makeindexk/Makefile.in
index ea8bd1c0d66..e763f11c44e 100644
--- a/Build/source/texk/makeindexk/Makefile.in
+++ b/Build/source/texk/makeindexk/Makefile.in
@@ -303,6 +303,7 @@ makeindex_SOURCES = \
mkind.c \
mkind.h \
qsort.c \
+ qsort.h \
scanid.c \
scanid.h \
scanst.c \
@@ -313,9 +314,9 @@ LDADD = $(KPATHSEA_LIBS)
dist_man1_MANS = makeindex.1 mkindex.1
EXTRA_DIST = CONTRIB NOTES $(TESTS) tests/nested-range.tex \
tests/nested-range.idx tests/nested-range-bb.tex \
- tests/nested-range-bb.idx
-TESTS = tests/nested-range-test.pl
-DISTCLEANFILES = nested-range.ilg nested-range.ind
+ tests/nested-range-bb.idx tests/sample.idx tests/sample.ind
+TESTS = tests/nested-range-test.pl tests/makeindex.test
+DISTCLEANFILES = nested-range.ilg nested-range.ind sample.*
all: c-auto.h
$(MAKE) $(AM_MAKEFLAGS) all-am
diff --git a/Build/source/texk/makeindexk/mkind.c b/Build/source/texk/makeindexk/mkind.c
index 63360fe320b..72f93d0449e 100644
--- a/Build/source/texk/makeindexk/mkind.c
+++ b/Build/source/texk/makeindexk/mkind.c
@@ -3,7 +3,7 @@
* This file is part of
* MakeIndex - A formatter and format independent index processor
*
- * Copyright (C) 1998-2011 by the TeX Live project.
+ * Copyright (C) 1998-2012 by the TeX Live project.
* Copyright (C) 1989 by Chen & Harrison International Systems, Inc.
* Copyright (C) 1988 by Olivetti Research Center
* Copyright (C) 1987 by Regents of the University of California
@@ -323,6 +323,9 @@ FATAL1("Option -g invalid, quote character must be different from '%c'.\n",
if (use_stdin) {
idx_fn = "stdin";
idx_fp = stdin;
+#ifdef WIN32
+ setmode(fileno(stdin), _O_BINARY);
+#endif
if (ind_given) {
if (!kpse_out_name_ok(ind_fn) ||
@@ -331,6 +334,9 @@ FATAL1("Option -g invalid, quote character must be different from '%c'.\n",
} else {
ind_fn = "stdout";
ind_fp = stdout;
+#ifdef WIN32
+ setmode(fileno(stdout), _O_BINARY);
+#endif
}
if (ilg_given) {
diff --git a/Build/source/texk/makeindexk/mkind.h b/Build/source/texk/makeindexk/mkind.h
index 7bfb5e6318b..fbc3de0a1f8 100644
--- a/Build/source/texk/makeindexk/mkind.h
+++ b/Build/source/texk/makeindexk/mkind.h
@@ -3,7 +3,7 @@
* This file is part of
* MakeIndex - A formatter and format independent index processor
*
- * Copyright (C) 1998-2011 by the TeX Live project.
+ * Copyright (C) 1998-2012 by the TeX Live project.
* Copyright (C) 1989 by Chen & Harrison International Systems, Inc.
* Copyright (C) 1988 by Olivetti Research Center
* Copyright (C) 1987 by Regents of the University of California
@@ -287,8 +287,8 @@ extern int mk_getc (FILE *str); /* line endings patch */
EXIT(1); \
}
-#define OPEN_IN(FP) fopen(FP, "r")
-#define OPEN_OUT(FP) fopen(FP, "w")
+#define OPEN_IN(FP) fopen(FP, "rb")
+#define OPEN_OUT(FP) fopen(FP, "wb")
#define CLOSE(FP) fclose(FP)
#define ISDIGIT(C) ('0' <= C && C <= '9')
@@ -546,9 +546,6 @@ fprintf(ilg_fp, \
extern void gen_ind (void);
extern int group_type (char *str);
-extern int main (int argc, char **argv);
-extern void qqsort (char *base, int n, int size,
- int (*compar)(char*,char*));
extern void scan_idx (void);
extern void scan_sty (void);
extern void sort_idx (void);
diff --git a/Build/source/texk/makeindexk/qsort.c b/Build/source/texk/makeindexk/qsort.c
index 9e98c4a240b..f784980989a 100644
--- a/Build/source/texk/makeindexk/qsort.c
+++ b/Build/source/texk/makeindexk/qsort.c
@@ -15,8 +15,7 @@
* bytes. The MTHREShold is where we stop finding a better median.
*/
-/* #include <stdio.h> -- mkind.h includes this */
-#include "mkind.h" /* only for type declarations */
+#include "qsort.h"
#define THRESH 4 /* threshold for insertion */
#define MTHRESH 6 /* threshold for median */
diff --git a/Build/source/texk/makeindexk/qsort.h b/Build/source/texk/makeindexk/qsort.h
new file mode 100644
index 00000000000..3bca7d6dbf2
--- /dev/null
+++ b/Build/source/texk/makeindexk/qsort.h
@@ -0,0 +1,12 @@
+/*
+ *
+ * This file is part of
+ * MakeIndex - A formatter and format independent index processor
+ *
+ * This file is public domain software donated by
+ * Nelson Beebe (beebe@science.utah.edu).
+ *
+ */
+
+extern void qqsort (char *base, int n, int size,
+ int (*compar)(char*,char*));
diff --git a/Build/source/texk/makeindexk/sortid.c b/Build/source/texk/makeindexk/sortid.c
index 6793481fc3e..b596846b2d7 100644
--- a/Build/source/texk/makeindexk/sortid.c
+++ b/Build/source/texk/makeindexk/sortid.c
@@ -3,7 +3,7 @@
* This file is part of
* MakeIndex - A formatter and format independent index processor
*
- * Copyright (C) 1998-2011 by the TeX Live project.
+ * Copyright (C) 1998-2012 by the TeX Live project.
* Copyright (C) 1989 by Chen & Harrison International Systems, Inc.
* Copyright (C) 1988 by Olivetti Research Center
* Copyright (C) 1987 by Regents of the University of California
@@ -26,6 +26,7 @@
*/
#include "mkind.h"
+#include "qsort.h"
#ifdef HAVE_LOCALE_H
#include <locale.h>
diff --git a/Build/source/texk/makeindexk/tests/makeindex.test b/Build/source/texk/makeindexk/tests/makeindex.test
new file mode 100755
index 00000000000..808e9f07393
--- /dev/null
+++ b/Build/source/texk/makeindexk/tests/makeindex.test
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+# Copyright (C) 2012 Peter Breitenlohner <tex-live@tug.org>
+# You may freely use, modify and/or distribute this file.
+
+TEXMFCNF=$srcdir/../kpathsea
+export TEXMFCNF
+
+rm -f sample.*
+
+./makeindex $srcdir/tests/sample.idx -o sample.ind1 -t sample.ilg1 \
+ && diff $srcdir/tests/sample.ind sample.ind1 || exit 1
+
+cat $srcdir/tests/sample.idx | ./makeindex >sample.ind2 2>sample.ilg2 \
+ && diff $srcdir/tests/sample.ind sample.ind2 || exit 1
+
diff --git a/Build/source/texk/makeindexk/tests/sample.idx b/Build/source/texk/makeindexk/tests/sample.idx
new file mode 100644
index 00000000000..394c0087af9
--- /dev/null
+++ b/Build/source/texk/makeindexk/tests/sample.idx
@@ -0,0 +1,15 @@
+\indexentry{alpha}{1}
+\indexentry{random text|bold}{2}
+\indexentry{random text|(}{9}
+\indexentry{random text|)}{11}
+\indexentry{alpha!beta}{3}
+\indexentry{alpha!phi}{5}
+\indexentry{alpha!phi!sigma}{6}
+\indexentry{alpha!phi!rho}{7}
+\indexentry{alpha!beta!delta}{8}
+\indexentry{alpha!beta!gamma}{10}
+\indexentry{alpha!phi!sigma}{12}
+\indexentry{alpha!phi!rho}{12}
+\indexentry{alpha!phi!sigma}{13}
+\indexentry{alpha!phi!sigma}{14}
+\indexentry{alpha!phi!rho}{14}
diff --git a/Build/source/texk/makeindexk/tests/sample.ind b/Build/source/texk/makeindexk/tests/sample.ind
new file mode 100644
index 00000000000..ea39facc389
--- /dev/null
+++ b/Build/source/texk/makeindexk/tests/sample.ind
@@ -0,0 +1,15 @@
+\begin{theindex}
+
+ \item alpha, 1
+ \subitem beta, 3
+ \subsubitem delta, 8
+ \subsubitem gamma, 10
+ \subitem phi, 5
+ \subsubitem rho, 7, 12, 14
+ \subsubitem sigma, 6, 12--14
+
+ \indexspace
+
+ \item random text, \bold{2}, 9--11
+
+\end{theindex}