summaryrefslogtreecommitdiff
path: root/indexing/makeindex/src
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /indexing/makeindex/src
Initial commit
Diffstat (limited to 'indexing/makeindex/src')
-rw-r--r--indexing/makeindex/src/LOG554
-rw-r--r--indexing/makeindex/src/Makefile357
-rw-r--r--indexing/makeindex/src/NOTES84
-rw-r--r--indexing/makeindex/src/RCS/README,v302
-rw-r--r--indexing/makeindex/src/RCS/mkind.h,v812
-rw-r--r--indexing/makeindex/src/README263
-rw-r--r--indexing/makeindex/src/genind.c477
-rw-r--r--indexing/makeindex/src/genind.h73
-rw-r--r--indexing/makeindex/src/make-kcc.mic13
-rw-r--r--indexing/makeindex/src/make-lc.bat9
-rw-r--r--indexing/makeindex/src/make-msc.bat7
-rw-r--r--indexing/makeindex/src/make-pcc.mic13
-rw-r--r--indexing/makeindex/src/make-tcc.bat7
-rw-r--r--indexing/makeindex/src/make-vms.com10
-rw-r--r--indexing/makeindex/src/makefile.bsd141
-rw-r--r--indexing/makeindex/src/makefile.kcc123
-rw-r--r--indexing/makeindex/src/makefile.lc139
-rw-r--r--indexing/makeindex/src/makefile.msc144
-rw-r--r--indexing/makeindex/src/makefile.os2138
-rw-r--r--indexing/makeindex/src/makefile.pcc124
-rw-r--r--indexing/makeindex/src/makefile.tcc146
-rw-r--r--indexing/makeindex/src/makefile.usg134
-rw-r--r--indexing/makeindex/src/makefile.vms124
-rw-r--r--indexing/makeindex/src/makeindx.def2
-rw-r--r--indexing/makeindex/src/mkind.c720
-rw-r--r--indexing/makeindex/src/mkind.h757
-rw-r--r--indexing/makeindex/src/qsort.c222
-rw-r--r--indexing/makeindex/src/scanid.c830
-rw-r--r--indexing/makeindex/src/scanid.h170
-rw-r--r--indexing/makeindex/src/scanst.c616
-rw-r--r--indexing/makeindex/src/scanst.h232
-rw-r--r--indexing/makeindex/src/sortid.c360
32 files changed, 8103 insertions, 0 deletions
diff --git a/indexing/makeindex/src/LOG b/indexing/makeindex/src/LOG
new file mode 100644
index 0000000000..7d31a56dd4
--- /dev/null
+++ b/indexing/makeindex/src/LOG
@@ -0,0 +1,554 @@
+ Revision History for MakeIndex
+
+This is a reverse time-ordered history of changes to MakeIndex.
+
+-----------------------------------------------------------------
+[19-Oct-1991]
+ Merged in small set of changes into mkind.c and mkind.h for
+ IBM VM/CMS support. Since there are no operational changes,
+ and 2.11 has only been distributed to the beta test list,
+ I'm leaving the version number at 2.11, and advancing the date.
+
+[11-Sep-1991]
+ Version 2.11 released by Nelson H.F. Beebe <beebe@math.utah.edu>
+
+ This version incorporates feedback from test sites for 2.10,
+ and importantly, replaces memory-gobbling fixed strings in the
+ index entries with dynamically-allocated strings, reducing the
+ storage per entry from 1844 bytes to 80 bytes + actual string
+ lengths. For details, see the new NOTES file. The use of
+ dynamic strings now lets MakeIndex 2.11 process all of the
+ entries in test/b209f.idx; with MakeIndex 2.10 and earlier, 6
+ were rejected because of long fields.
+
+ Reorder two lines in doc/makeindex.l to avoid single quote at
+ beginning of line, which nroff and troff then lose.
+
+ Move typeout of version string in mkind.c to before parsing of
+ style file; otherwise, MakeIndex can terminate with an error
+ message before identifying itself.
+
+ Correct argument parsing in mkind.c to check for a following
+ argument before assuming it is there.
+
+ Change long macro PUT_HEADER in genind.h to function
+ put_header() in genind.c; it was too long for some compilers.
+
+ Correct bad args to STY_ERROR2() in scanst.c (had LINE_MAX
+ instead of LINEMAX).
+
+ Correct array dimension in flush_line() in genind.c from
+ tmp[LINE_MAX] to tmp[sizeof(buff)]; long index entries
+ otherwise overwrote stack storage.
+
+ Correct array dimension in mkind.c from pageno[STRING_MAX] to
+ pageno[NUMBER_MAX].
+
+ Correct array dimension in scanid.c from keyword[STRING_MAX]
+ to keyword[ARRAY_MAX].
+
+ Correct two array dimensions in genind.c from 2*STRING_MAX to
+ 2*ARGUMENT_MAX.
+
+ Document array sizes xxx_MAX in mkind.h (note above corrections).
+
+ Add more code in scanid.c to check for overflow of field[]. A
+ case was found where overwriting occurred if an idx_escape is
+ found when i == ARRAY_MAX - 1. In this new version, the length
+ is no longer ARRAY_MAX, but is passed as an additional argument
+ to the function scan_field().
+
+ In sortid.c, change type of idx_gc from `int' to `long' to avoid
+ integer overflow or wraparound when there are more than 32767
+ (or whatever the host INT_MAX value is) comparisons.
+
+ Change two tests in scanid.c in scan_roman_lower() and
+ scan_roman_upper() from "if (... && (new = ...))" to
+ "if (... & ((new = ...) != 0))" to suppress compiler warnings on
+ some systems about possible error in use of = instead of ==.
+
+ Add test/b211a.idx to test MakeIndex with very long
+ index fields near, at, and beyond the standard internal array
+ dimensions.
+
+ Add test/b211b.{idx,ist} to test MakeIndex with the German
+ sort option.
+
+ Add missing "level = i;" in genind.c; this fixes an obscure bug
+ that is seen only when certain style files are used. The
+ test/b211b.idx file tests the fix.
+
+ Lattice has gone out of business, so the files src/make-lc.bat
+ and src/makefile.lc are in some sense obsolete, and will receive
+ no further maintenance. They are retained in the distribution
+ for now because some sites may still be using that compiler.
+
+ Revise scanid.c to permit idx_quote (by default, a quotation
+ mark) to quote ANY input character in the first argument to
+ the indexentry macro. Revise sortid.c to use unsigned char
+ data for sorting, removing architecture dependence. This also
+ requires a change in the TOLOWER and TOUPPER macros in mkind.h.
+ This is an important extension to MakeIndex: it permits sort
+ keys to be created for all ASCII characters, including braces
+ and others that otherwise have significance to MakeIndex (by
+ default, @, |, !). It also permits the user to get characters
+ 1..255 into the actual field; this will be important for TeX
+ 3.0 which can support a 256-character set. Character 0 cannot
+ be easily supported, because it is a string terminator in C,
+ the language in which MakeIndex is currently implemented. A
+ future extension might support an escape mechanism for it.
+ Too bad MakeIndex was not originally designed to support
+ C-like \ooo (octal) and \xhh (hexadecimal) escape sequences!
+ The file test/b211e.idx tests the sorting and display of all
+ characters in 1..255, and the file test/b211e.ltx typesets the
+ test index. Because Ctl-Z is an end-of-file marker in PC DOS
+ text files, test/b211h.idx is derived from test/b211e.idx by
+ removing the line with that character, and used in dosdiff.bat
+ in place of b211e. Note that MakeIndex collates space and the
+ characters in 1..31 and 127..255 somewhat differently than
+ ASCII. The MakeIndex order is:
+
+ punctuation characters (in ASCII order),
+ digits,
+ control characters (1..31),
+ space (32),
+ letters (ignoring case),
+ characters 127 .. 255.
+
+ In prepare_idx() in mkind.c, add a check for a NULL `head';
+ this can arise if the input file is garbage (e.g. you type
+ makeindex foo, meaning foo.idx, but a foo file already exists,
+ and is used instead of foo.idx). Without this check, a NULL
+ pointer is subsequently dereferenced, with core dumps on some
+ machines. The problem really lies in process_index() in
+ mkind.c, where idx_tc gets incremented before we know we have
+ a valid entry, such that in main(), idx_gt gets set to 1, when
+ `head' is still NULL. It seems easier to catch this error in
+ prepare_idx() instead of process_index().
+
+ Add additional architecture-specific targets to Makefile
+ to incorporate the compiler switches shown under the 2.10
+ LOG file entry below.
+
+ The book.idx file is still too big for a Turbo C 2.0 compiled
+ version of MakeIndex 2.11 on MS DOS to handle.
+
+ Fix several loops that called GET_CHAR() without checking
+ for an EOF result (genind.c, mkind.c, mkind.h, scanid.c,
+ scanst.h).
+
+ Fix range handling error in compare_page() in sortid.c; the file
+ test/b211f.idx tests that the fix is correct.
+
+ Incorporate bug repairs from:
+
+ Eberhard Mattes <mattes@azu.informatik.uni-stuttgart.de>
+
+ Mark James <mark@bdblues.altair.fr>, <mark@nuri.inria.fr>
+
+-----------------------------------------------------------------
+[05-Jul-1991]
+ Version 2.10 released by Nelson H.F. Beebe <beebe@math.utah.edu>
+
+ Testing of this version has been carried out on these systems:
+
+ =================================== =================
+ System Compile Defines
+ =================================== =================
+ Apollo DN/10000 -DOS_SYSV -U__STDC__
+ DECstation Ultrix 4.2
+ HP 375 (4.3BSD)
+ HP 9000/720 (HP-UX, System V UNIX) -DOS_SYSV
+ HP 9000/850S (HP-UX, System V UNIX) -DOS_SYSV
+ IBM 3090/600S-VF AIX -D_BSD
+ IBM PC DOS
+ IBM RS/6000 AIX 3.1
+ NeXT Mach
+ Silicon Graphics 4D-240 -DOS_SYSV
+ Stardent 1520 UNIX Release 2.2
+ SunOS 4.1.1 (BSD UNIX)
+ VAX VMS 5.3
+ =================================== =================
+
+ This version addresses all outstanding bug reports that I am
+ aware of, and brings the code completely up to the level of
+ Standard C (ANSI X3.159-1989 Programming Language--C, ISO C
+ 1990).
+
+ In test/, rename long filenames to shorter ones, and add
+ several new test files, and a Makefile to automate the testing
+ of a new version on UNIX.
+
+ Add a README file with compilation instructions.
+
+ In mkind.c, mkind.h, and scanst.c, rename LONG_MAX to
+ ARRAY_MAX. LONG_MAX is used in Standard C for the largest
+ long integer.
+
+ In mkind.h, drop IBM_PC_LATTICE. There were no uses of it
+ elsewhere in the code, and Lattice is no longer in business, and
+ Microsoft C and Turbo C are now the major compilers on PC DOS
+ (Waterloo and TopSpeed lag far behind). Existing support for
+ TOPS-20 will be retained for now, even though by the end of
+ 1991, there may not be any more TOPS-20 systems alive; ours was
+ retired 31-Oct-1990, and the American Mathematical Society's on
+ 31-Mar-1991.
+
+ In mkind.h, except in OS_PCDOS, increase STRING_MAX from 128 to
+ 256, and in genind.c, change dimensions of 2*LINE_MAX to
+ 2*STRING_MAX. Anita Hoover <anita@brahms.udel.edu> reported a
+ need for this.
+
+ Fix sort bug reported by Andreas Brosig <brosig@gmdzi.gmd.de>
+ and Ed Sznyter <ews@Pescadero.Stanford.EDU>. This bug was
+ introduced in sortid.c at version 2.8 by the fix for another
+ bug. The code in compare_page() did not handle the case where
+ two entries were the same in index fields and page numbers, but
+ differed in their encap fields. The resulting incorrect
+ comparison could then later cause bogus page ranges to be
+ produced. Test file b209e.idx has been included for future
+ testing. From version 2.10, bugs reported in version x.yy will
+ have files test/bxyy*.idx (* = a, b, ...) that will be preserved
+ for regression testing.
+
+ In doc/, in the manual page file, makeindex.l, alphabetize
+ command-line switch descriptions, correct some spelling errors,
+ and add new descriptions. Add a Makefile and targets to
+ automatically create the .dvi, .hlp, .info, .ps, and .vms files,
+ and to install and uninstall the manual pages. The .hlp, .info,
+ .ps, and .vms files will be included with the distribution since
+ they can be generated only on some UNIX systems.
+
+ In paper/, add a Makefile, and create LaTeX picture mode
+ equivalent of fig1.ps, so that ind.tex can be formatted and
+ printed at any TeX installation. Remove the old output
+ PostScript file, ind.ps, saving 300KB of disk space, since it is
+ no longer needed.
+
+ Incorporate additional contributions from:
+
+ Johannes Braams <braams@hlsdnl5.bitnet> (bug fixes for
+ VAX VMS)
+
+ Joachim Schrod <xitijsch@ddathd21.bitnet> (2.9.1
+ changes)
+
+ Rainer Schoepf <bk4@dhdurz1.bitnet> (more Atari TOS
+ changes)
+
+ Eberhard Mattes <mattes@azu.informatik.uni-stuttgart.de>
+ (OS/2 Makefile and .def description file)
+
+ Richard P. C. Rodgers <rodgers@maxwell.mmwb.ucsf.edu>
+ (manual page additions)
+
+------------------------------------------------------------------------
+[22-Jun-1990]
+ Version 2.9.1 by Joachim Schrod <xitijsch@ddathd21.bitnet>
+
+ Testing carried out on:
+ PC DOS Microsoft C 5.1
+ BSD Sun OS 4.0 cc
+ gcc 1.37.1
+ System V R3 MUNIX cc
+ IBM AIX/2 cc
+ IBM AIX/370 cc
+
+ Added difference between BSD (OS_BSD) and System V R3 (OS_SYSV).
+ Deleted UNIX (OS_UNIX).
+
+ There doesn't exist a single `UNIX' system, e.g. the naming of
+ index/rindex versus strchr/strrchr may be called a `cultural
+ difference'.
+
+ Updated comments concerning the preprocessor constants to reflect
+ the actual state of the source.
+
+ Please note that the Atari port seems to be incorrect; look for
+ FIXME in mkind.h.
+
+ By the way, it is not mentioned what compiler is used on the
+ Atari -- it is one that uses index/rindex.
+
+-----------------------------------------------------------------
+[12-Dec-1989]
+ Version 2.9 released by Nelson H.F. Beebe <beebe@math.utah.edu>
+
+ Testing carried out on:
+ PC DOS Microsoft C 5.0, Turbo C 2.0, Lattice C 6.02
+ TOPS-20 KCC-20 and PCC-20
+ UNIX Sun OS 4.0.3 cc and gcc 1.36
+ VAX ULTRIX-32 cc
+ VAX VMS VMS C 2.3
+
+ Added support for Turbo C 2.0 and Lattice C 6.02 on IBM PC DOS.
+
+ Although compilation and linking were successful with Lattice
+ C, the executable produced a 'Not enough core...abort' message
+ at run time under the D, L, and H memory models. Replacing
+ malloc(n) calls by halloc(1L,n) did not remove the problem;
+ debugging statements (selected by defining DEBUG at compile
+ time) showed that calls to malloc() and calloc() allocated
+ less than 15KB before the abort. Curiously, a separate little
+ test program that allocated 1000-byte blocks with malloc() or
+ calloc() could allocate over 55KB in the small memory model,
+ and over 500KB in the large models, before aborting. Thus, we
+ conclude for now that Lattice C 6.02 is not usable for
+ MakeIndex.
+
+ Added ARGS macro to simplify function declarations in ANSI and
+ pre-ANSI styles.
+
+ Added missing definition of OS_XENIX in mkind.h.
+
+ Moved declarations of static functions from mkind.h to relevant
+ *.c files to remove compiler warnings about declared, but unused,
+ objects.
+
+ Removed a couple of unreachable break statements that raised
+ compiler warnings.
+
+ Use ANSI strchr/strrchr instead of K&R index/rindex; the former
+ are #defined to the latter for systems that have only the old
+ names.
+
+ Fixed scan_arabic() in scanid.c to allow ARABIC_MAX digits,
+ instead of one less than that, and fix condition on which the
+ error message about too many Arabic digits is triggered.
+
+ Repair widespread confusion between NUL (the character '\0'),
+ and NULL (the pointer). NUL is a user-definable name, while
+ NULL is defined by the implementation; on segmented memory
+ machines, pointers and integers need not be equivalent, so it
+ may hold that NULL != NUL. Previous versions of MakeIndex used
+ NULL to mean both, and redefined NULL to be '\0'. In general,
+ NULL must be typecast to a pointer of the appropriate type,
+ since under ANSI C, it will usually be defined to be something
+ like (void*)0 or (void*)0L.
+
+-----------------------------------------------------------------
+[11-Nov-1989]
+ Version 2.8 released by Pehong Chen <chen@renoir.berkeley.edu>.
+ (1) ARABic_MAX changed from 4 to 5, duo to Sebastian Rahtz's
+ <spqr%ecs.southampton.ac.uk@NSFnet-Relay.AC.UK> report
+ on TeXhax #87 (9/17/1989).
+ (2) A nasty sorting bug was fixed due to a report from
+ Martha Wershofen-Mersbach <GRZTEX%dbngmd21.bitnet@NET.BIO.NET>
+ of the German National Research Center For Computer Science (GMD).
+ (3) Siemens BS2000 ported done by Andreas Brosig of the German
+ National Research Center For Computer Science (GMD).
+ (4) German word ordering, the "-g" option contributed by Brosig.
+ (5) Miscellaneous bug fixes by Brosig:
+ A. Blank compression routine ("-c") fixed.
+ B. The "-p" option now works for MSDOS and MVS. Have to open
+ logfile in binary mode for OS_PCDOS and add OS_MVSXA to an
+ existing #if because fseek(...) does not work under MVS.
+ C. If an indexentry contains more than 2 IDX_LEVEL '!' or more
+ than 3 IDX_ACTUAL '@', MakeIndex would ignore this entry
+ and writes "Extra ... at position ..." to the transcript file.
+ This is now fixed.
+ D. If an indexentry is too long (> STRING_MAX), MakeIndex would
+ ignore it and write a message to the transcript file.
+ This is now fixed.
+ E. For MSDOS(OS_PCDOS) LONG_MAX is set back to 144
+ and STRING_MAX to 64. Otherwise a core error will occur
+ in the case of a big IDX-file.
+
+-----------------------------------------------------------------
+[1-Oct-1988]
+ Version 2.7 released by Pehong Chen <chen@orc.olivetti.com>.
+ (1) Fixed a string printing bug reported by anita@brahms.udel.edu
+ through Leslie Lamport. The string should be an argument
+ to the printf format, instead of the format itself.
+
+-----------------------------------------------------------------
+[14-Jul-1988]
+ Version 2.6 released by Pehong Chen <chen@orc.olivetti.com>.
+ (1) The documentation for UNIX man page makeindex.l went through
+ revision by Rick P. C. Rodgers of UCSF <rodgers@cca.ucsf.edu>.
+ Rick also provided a sample style file for MakeIndex to work
+ with troff (see the man page for details).
+ (2) String length (LONG_MAX) was increased from 144 to 1024.
+ (3) Fixed a letter heading bug. It used to put the heading
+ below the first index entry.
+ (4) Added a new feature, the terminating delimiter for page list.
+ This delim_t string is null by default. It can be redefined
+ as a period if one would like a page list to be terminated
+ by a period, for example. This delimeter has no effect
+ on an index entry which does not have any page number
+ associated with it.
+
+-----------------------------------------------------------------
+[14-Apr-1988]
+ Version 2.5 released by Pehong Chen <phc@berkeley.edu>,
+ with VAX/VMS extensions by
+ Charles Karney
+ Plasma Physics Laboratory Phone: +1 609 243 2607
+ Princeton University MFEnet: Karney@PPC.MFEnet
+ PO Box 451 ARPAnet: Karney%PPC.MFEnet@NMFECC.ARPA
+ Princeton, NJ 08543-0451 Bitnet: Karney%PPC.MFEnet@ANLVMS.Bitnet
+ The file VMSmake.com for VAX/VMS users who don't have make.
+ This version also includes a fix under XENIX by
+ Baron O.A. Grey UCLA Computer Science Department
+ baron@CS.UCLA.EDU ...!(ucbvax,ihnp4)!ucla-cs!baron
+
+-----------------------------------------------------------------
+[20-Mar-1988]
+ Version 2.4 released by Pehong Chen <phc@berkeley.edu>,
+ the ``official'' version of MakeIndex that enters public domain.
+
+ * length() (originally defined in mkind.c) is replaced by
+ the standard function strlen(), which in some C implementations
+ is, or can be, expanded to in-line efficient hardware instructions
+ (e.g. Microsoft C and VAX Unix); I have not yet done this.
+
+-----------------------------------------------------------------
+[20-Jan-1988]
+ Portable version 2.3 released by Nelson H.F. Beebe
+ <beebe@math.utah.edu>.
+
+ I spent 3 days implementing MakeIndex on Sun OS3.3 Unix
+ (cc and gcc), TOPS-20 (KCC-20 and PCC-20 compilers), PC
+ DOS (Microsoft C Version 5.0), and VAX VMS. This was at
+ times a frustrating experience, because the effort
+ revealed a great many portability problems in the
+ original code (from VAX Unix, I think), plus some genuine
+ bugs in MakeIndex, plus a bug in each of two compilers
+ (KCC-20 and PCC-20)!
+
+ The changes for this version over 2.2 are exclusively bug
+ fixes and portability enhancements. Thanks to the
+ original authors' careful design, no functionality
+ changes are likely to be necessary.
+
+ Besides getting the code working correctly on 4 systems
+ and 6 compilers, I have made several passes over the code
+ to reduce the lint complaints to a minimum, and remove
+ all of the warnings produced by the IBM PC Microsoft C
+ Version 5.0 compiler, which is the only one of the above
+ systems which completely implements October 1986 draft
+ ANSI C; the ANSI function prototype checking caught
+ numerous problems.
+
+ With these changes, I believe that we now have a version
+ of MakeIndex that satisfies the important goal of TeX --
+ the same input will produce identical output results on
+ all machines, whether they be micros, minis, mainframes,
+ or supercomputers. This is true at least for the 6
+ systems for which testing has been possible at Utah.
+
+ Here is a summary of bug corrections and other changes:
+
+ * Several routines fell off the end without returning a
+ value, when the caller expected it; this was particularly
+ hard to trace (2 days of effort--the code only failed on
+ PCC-20, and work correctly with the other 4).
+
+ * Equivalence of *short and *int was incorrectly assumed
+ in one routine; this made the code dependent on the byte
+ storage order (it works on the little-Endian VAX
+ architecture, but will fail on big-Endian architectures
+ (IBM et al)).
+
+ * Equivalence of *int and *char was incorrectly assumed
+ in the call to qsort(); the only one of the 6 compilers
+ which uses a different format for *char values is KCC-20,
+ and that feature caught this bug (the compiler didn't
+ find it for me, but when the sort failed, I tracked it down).
+
+ * Routines which do not return a value are now explicitly
+ typed `void' instead of nothing or `int', and mkind.h has
+ both K&R old-style and new ANSI style function
+ declarations for all routines; the choice is made on the
+ basis of the compiler and operating-system switch
+ selections.
+
+ * A single (incorrect) use of backslash-dot (\.) escape
+ sequence in scanid.h has been reduced to dot (.).
+
+ * exit() was called without a valid argument in mkind.h.
+
+ * In several places, code of the form
+ char c;
+ while ((c = getchar()) != EOF)
+ existed; this is incorrect and will fail on many machines
+ when the EOF (== -1) value returned by getchar() is
+ truncated to a byte value for storage in c, then extended
+ to an integer again and compared with EOF. The correct
+ approach is to use "int c;" instead of "char c;". Type
+ declarations have been changed from "short" or "int" to
+ "char" or vice versa in several places in order to
+ achieve consistency, and explicit typecasts are used when
+ data types are intentionally changed by assignment or
+ argument association.
+
+ * mkind.h now has a SHORTNAMES section to define short
+ names for the 45 long ones which clash when reduced to 6
+ characters (although KCC-20 and PCC-20 both handle long
+ names, they produce assembly code output, and the
+ assembler limits names to 6 case-insensitive chars).
+
+ * File names have been reduced to 6 characters, allowing
+ the source to be ported to all of the above systems
+ without tedious file renaming. The TOPS-20 LINK program
+ also runs under TOPS-10, and because TOPS-10 has a
+ 6-character file name limit, LINK-20 does too, sigh...
+ The executable is called makeindex on all systems except
+ PC DOS, where the 8-character limit reduces it to
+ makeindx. Similarly, filenames with special characters
+ (ind+ and ind-) have been renamed to portable names.
+
+ * Reference to sys/file.h has been eliminated; it was
+ only needed for the symbol R_OK passed to access().
+ sys/file.h is missing from most non-Unix C
+ implementations, while the value of R_OK (4) for access()
+ is consistent for all but PCC-20, where only F_OK (0) is
+ implemented.
+
+ * Makefiles have been produced for each of the above
+ systems (I have the same version of a public-domain make
+ running on all of them).
+
+ * A public version of qsort.c has been included in
+ MakeIndex for two reasons. First, some non-Unix C
+ implementations lack it. Second, quicksort is not a
+ `stable' sorting algorithm; that is, the order of items
+ with equal keys is not necessarily identical between the
+ input and the output. Different implementations of the
+ sort algorithm in the host qsort() can therefore give
+ different ordering in such cases (PCC-20 and KCC-20
+ differed, which is how I caught this). qsort is
+ #define'd to qqsort for all systems, in order to avoid
+ possible clashes with the standard library version (this
+ happens with IBM PC Microsoft C and with VAX VMS).
+
+ * Version 2.2 did not come with any documents containing
+ index entries to test MakeIndex with. I have taken the
+ liberty of preparing an index for Leslie Lamport's
+ article, ../doc/makeindex.tex for a test version,
+ ../test/test.tex. This can be used both to test MakeIndex,
+ as well as to illustrate the production of an index for
+ new users (I'm using it in a class that I am teaching on
+ LaTeX). test.tex uses the showidx document style option
+ to get the index entries displayed as marginal notes, and
+ the index entries in test.tex have been carefully
+ formatted to always begin a line; that way, they can be
+ easily extracted (e.g. by grep), so that one can see the
+ original entries, the LaTeX output .idx file, and the
+ MakeIndex output .ind file.
+
+ * The bug fix for PCC-20 has been posted to the TOPS-20
+ bulletin board; PCC-20 was developed at CS.UTAH.EDU, but
+ we (SCIENCE.UTAH.EDU) now have their DEC-20, so I guess
+ we have become the default PCC bug-fix site. The bug in
+ KCC-20's preprocessor has been reported to the KCC
+ developers at SRI-NIC.ARPA but cannot be easily fixed
+ until the draft ANSI C support in KCC-20 is complete; in
+ the meantime, conditional compilation is used to provide
+ alternate code which compiles correctly.
+
+-----------------------------------------------------------------
+[29-May-1987]
+ Version 2.2 (5/29/1987) released by Pehong Chen <phc@berkeley.edu>.
+
+-----------------------------------------------------------------
diff --git a/indexing/makeindex/src/Makefile b/indexing/makeindex/src/Makefile
new file mode 100644
index 0000000000..d833e47765
--- /dev/null
+++ b/indexing/makeindex/src/Makefile
@@ -0,0 +1,357 @@
+#=======================================================================
+# Makefile for the program `makeindex'
+#
+# Copyright (C) 1987 Pehong Chen (phc@renoir.berkeley.edu)
+# Computer Science Division
+# University of California, Berkeley
+#
+# On many UNIX systems, do
+# make
+# to build MakeIndex, and
+# make install
+# to install it. You may need to modify BINDIR, MANDIR, and MANEXT
+# for your system.
+#
+# For systems that require different compile flags, there are
+# additional targets apollo .. vms that can be used, e.g.
+# make hp720
+#
+# Current target list:
+# all
+# $(BINDIR)/$(PROGRAM)
+# distclean
+# depend
+# dist
+# index
+# install
+# man
+# mostlyclean
+# print
+# program
+# $(PROGRAM)
+# realclean
+# reallyclean
+# shar
+# tar
+# tags
+# TAGS
+# test
+# uninstall
+# update
+#
+# apollo
+# du42
+# du43
+# du42-gcc
+# du43-gcc
+# du42-lcc
+# du43-lcc
+# hp375
+# hp720
+# hp850
+# hp850-c89
+# ibm370
+# ibm370-c++
+# ibmpc
+# ibmps2
+# ibmrs6000
+# ibmrs6000-c++
+# mips
+# next
+# next-g++
+# next-objc
+# sgi
+# sgi-c++
+# sgi-g++
+# solaris
+# solaris-apcc
+# solaris-c++
+# solaris-g++
+# stardent
+# sun
+# sun-apcc
+# sun-c++
+# sun-g++
+# vms
+#
+# [26-May-1993] -- update for 2.12beta release (add GNU Project
+# standard targets, alphabetize macros and targets,
+# replace use of install command)
+# [20-Apr-1993] -- remove references to system include files
+# [07-Aug-1991]
+#=======================================================================
+
+ALL = $(MAKEFILE) $(DOC) $(MANUAL) $(HDRS) $(SRCS)
+
+BINDIR = /usr/local/bin
+
+CFLAGS = -O
+
+CHMOD = chmod
+
+CP = /bin/cp
+
+DOC = makeindex.tex
+
+#EXTHDRS = /usr/include/ctype.h \
+# /usr/include/stdio.h
+
+HDRS = genind.h \
+ mkind.h \
+ scanid.h \
+ scanst.h
+
+LDFLAGS = $(CFLAGS)
+
+LIBS =
+
+LINKER = $(CC)
+
+MAKEFILE = Makefile
+
+MANDIR = /usr/local/man/man1
+
+MANEXT = 1
+
+MANUAL = makeindex.l
+
+OBJS = genind.o \
+ mkind.o \
+ qsort.o \
+ scanid.o \
+ scanst.o \
+ sortid.o
+
+PRINT = psgrind
+
+PROGRAM = makeindex
+
+RM = /bin/rm -f
+
+SHAR = $(PROGRAM).shar
+
+SHELL = /bin/sh
+
+SRCS = genind.c \
+ mkind.c \
+ qsort.c \
+ scanid.c \
+ scanst.c \
+ sortid.c
+
+STRIP = strip
+
+TAR = $(PROGRAM).tar
+
+#=======================================================================
+
+all: $(PROGRAM)
+
+$(BINDIR)/$(PROGRAM): $(SRCS) $(HDRS) $(EXTHDRS)
+ @$(MAKE) -f $(MAKEFILE) BINDIR=$(BINDIR) install
+
+clean mostlyclean:
+ -$(RM) $(OBJS)
+ -$(RM) $(PROGRAM)
+ -$(RM) *.out
+ -$(RM) *~
+ -$(RM) \#*
+ -$(RM) core
+
+clobber realclean reallyclean: clean
+
+distclean: clobber
+ -$(RM) $(SHAR) $(TAR) tags TAGS
+
+depend:
+ -@$(RM) -f .#*.[chly]
+ mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) BINDIR=$(BINDIR)
+
+dist:
+ $(CP) $(PROGRAM) $(BINDIR)
+ rcp $(PROGRAM) monet:$(BINDIR)
+ rcp $(PROGRAM) arpa:$(BINDIR)
+ rcp $(PROGRAM) harrison@vangogh:bin
+
+index:
+ @ctags -wx $(HDRS) $(SRCS)
+
+install: $(PROGRAM)
+ $(CP) $(PROGRAM) $(BINDIR)/$(PROGRAM)
+ $(STRIP) $(BINDIR)/$(PROGRAM)
+ $(CHMOD) 0755 $(BINDIR)/$(PROGRAM)
+ $(CP) ../doc/$(MANUAL) $(MANDIR)/makeindex.$(MANEXT)
+ $(CHMOD) 0744 $(MANDIR)/makeindex.$(MANEXT)
+ @ls -lgs $(BINDIR)/$(PROGRAM) $(MANDIR)/makeindex.$(MANEXT)
+
+man:
+ ptroff -man $(MANUAL)
+
+print:
+ @$(PRINT) $(HDRS) $(SRCS)
+
+program: $(PROGRAM)
+
+$(PROGRAM): $(OBJS)
+ -@$(RM) -f $(PROGRAM)
+ $(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)
+ @size $(PROGRAM)
+
+shar:
+ -@$(RM) -f $(SHAR)
+ shar $(SHAR) $(ALL)
+
+tar:
+ -@$(RM) $(TAR)
+ tar -cf $(TAR) $(ALL)
+
+tags: $(HDRS) $(SRCS)
+ @ctags $(HDRS) $(SRCS)
+
+TAGS: $(HDRS) $(SRCS)
+ @etags $(HDRS) $(SRCS)
+
+test: $(PROGRAM)
+ cd ../test ; $(MAKE)
+
+uninstall:
+ -$(RM) $(BINDIR)/$(PROGRAM)
+ -$(RM) $(MANDIR)/makeindex.$(MANEXT)
+
+update: $(BINDIR)/$(PROGRAM)
+
+.DEFAULT:
+ co $@
+
+#=======================================================================
+# Machine-specific targets to simplify installation when additional
+# compile flags are needed.
+#
+# Apollo DN/10000
+apollo:
+ $(MAKE) CFLAGS='-DOS_SYSV -U__STDC__' $(PROGRAM)
+
+# DECstation Ultrix 4.2 and 4.3
+du42 du43: all
+
+# DECstation Ultrix 4.2 and 4.3 with gcc
+du42-gcc du43-gcc:
+ $(MAKE) CC=gcc $(PROGRAM)
+
+# DECstation Ultrix 4.2 and 4.3 with lcc
+du42-lcc du43-lcc:
+ $(MAKE) CC=lcc CFLAGS= $(PROGRAM)
+
+# HP 375 (4.3BSD)
+hp375: all
+
+# HP 9000/720 (HP-UX, System V UNIX)
+hp720:
+ $(MAKE) CFLAGS='-DOS_SYSV' $(PROGRAM)
+
+# HP 9000/850S (HP-UX, System V UNIX)
+hp850:
+ $(MAKE) CFLAGS='-DOS_SYSV' $(PROGRAM)
+
+# HP 9000/850S (HP-UX, System V UNIX) with Standard C compiler
+hp850-c89:
+ $(MAKE) CC=c89 CFLAGS='-DOS_SYSV' $(PROGRAM)
+
+# IBM 3090/600S-VF AIX
+ibm370:
+ $(MAKE) CFLAGS='-D_BSD' $(PROGRAM)
+
+# IBM 3090/600S-VF AIX with C++
+ibm370-c++:
+ $(MAKE) CC-'CC +a1 +p +w -D_POSIX_SOURCE -Hansi -D__STDC__ \
+ -D_BSD -D_AIX -D_AIX370' CFLAGS='-D_BSD' $(PROGRAM)
+
+# IBM PC DOS
+ibmpc: all
+
+# IBM PS/2 AIX 2.1
+ibmps2: all
+
+# IBM PS/2 AIX 2.1 with C++
+ibmps2-c++:
+ $(MAKE) CC='CC +a1 +p +w -D_POSIX_SOURCE -Hansi -D__STDC__ \
+ -D_BSD -D_AIX -Dps2' CFLAGS='-D_BSD' $(PROGRAM)
+
+# IBM RS/6000 AIX 3.1
+ibmrs6000:
+ $(MAKE) $(PROGRAM)
+
+# IBM RS/6000 AIX 3.1 with C++
+ibmrs6000-c++:
+ $(MAKE) CC=xlC $(PROGRAM)
+
+# MIPS R6000 RISC/os 5.0
+mips:
+ $(MAKE) CFLAGS='-DOS_SYSV -O' $(PROGRAM)
+
+# NeXT Mach
+next: all
+
+# NeXT Mach with C++
+next-g++:
+ $(MAKE) CC=g++ $(PROGRAM)
+
+# NeXT Mach with Objective C
+next-objc:
+ $(MAKE) CC='cc -ObjC' $(PROGRAM)
+
+# Silicon Graphics IRIX 3.x and 4.x
+sgi:
+ $(MAKE) CFLAGS='-DOS_SYSV -O2' $(PROGRAM)
+
+sgi-c++:
+ $(MAKE) CC=CC CFLAGS='-DOS_SYSV -O2' $(PROGRAM)
+
+sgi-g++:
+ $(MAKE) CC=g++ CFLAGS='-DOS_SYSV -O2' $(PROGRAM)
+
+# Sun Solaris 2.x (AT&T SysVR4): must compile in ANSI environment
+solaris:
+ $(MAKE) CFLAGS='-Xc -xO4' all
+
+# Sun Solaris 2.x (AT&T SysVR4) with Apogee C
+solaris-apcc:
+ $(MAKE) CC='apcc -Xc=ansi' CFLAGS='-O4' all
+
+# Sun Solaris 2.x (AT&T SysVR4) with C++
+solaris-c++:
+ $(MAKE) CC=CC CFLAGS='-O4' all
+
+# Sun Solaris 2.x (AT&T SysVR4) with C++
+solaris-g++:
+ $(MAKE) CC=g++ all
+
+# Stardent 1520 UNIX Release 2.2
+stardent: all
+
+# SunOS 4.1.x (BSD UNIX)
+sun: all
+
+# SunOS 4.1.x (BSD UNIX) with Apogee C
+sun-apcc:
+ $(MAKE) CC=apcc all
+
+# SunOS 4.1.x (BSD UNIX) with C++
+sun-c++:
+ $(MAKE) CC=CC all
+
+# SunOS 4.1.x (BSD UNIX) with g++
+sun-g++:
+ $(MAKE) CC=g++ all
+
+# VAX VMS 5.3
+vms: all
+
+#=======================================================================
+###
+genind.o: mkind.h genind.h
+mkind.o: mkind.h
+qsort.o: mkind.h
+scanid.o: mkind.h scanid.h
+scanst.o: mkind.h scanst.h
+sortid.o: mkind.h
diff --git a/indexing/makeindex/src/NOTES b/indexing/makeindex/src/NOTES
new file mode 100644
index 0000000000..ca81552fe5
--- /dev/null
+++ b/indexing/makeindex/src/NOTES
@@ -0,0 +1,84 @@
+ Investigation of Size Reduction in MakeIndex
+ [25-Jul-1991]
+
+Joachim Schrod in his work on MakeIndex 3.0 (to be reported at
+EuroTeX'91 in Paris, September 1991) found that substantial
+storage economizations in MakeIndex are possible by dynamically
+allocating some arrays. Since that version is not yet available, it
+seemed worthwhile to try to apply such changes to version 2.10, making
+version 2.11.
+
+The major memory consumption in MakeIndex is by the arrays af[][] and
+sf[][] in
+
+#define FIELD_MAX 3
+#define STRING_MAX 256
+
+typedef struct KFIELD
+{
+ char sf[FIELD_MAX][STRING_MAX]; /* sort key */
+ char af[FIELD_MAX][STRING_MAX]; /* actual key */
+...
+} FIELD, *FIELD_PTR;
+
+These arrays are referenced in genind.c, scanid.c, and sortid.c. They
+are defined in mkind.h, and initialized to empty strings in scanid.c.
+
+Each index entry has one such struct KFIELD slot, and with current
+dimension limits, sizeof(FIELD) == 1844. book.idx has 4241 index
+entries, so we need 1844*4241 = 7820404 bytes of dynamic storage.
+However, book.idx is only 142027 bytes long, and in entry, 16
+characters ("\indexentry{}{}") need not be stored; the true storage
+requirement is therefore 142027 - 4241*16 = 74171 so 99.05% of the
+storage is being wasted,
+
+After sorting and removal of duplicate lines, book.idx reduces to
+85935 bytes and 2531 entries, so the actual storage required is
+1844*2531 = 4667164 bytes; the wastage is still high: 98.4%.
+
+If we change to
+
+typedef struct KFIELD
+{
+ char *sf[FIELD_MAX]; /* sort key */
+ char *af[FIELD_MAX]; /* actual key */
+...
+} FIELD, *FIELD_PTR;
+
+then sizeof(FIELD) = 332, and the required storage is 332*2531 =
+840292 bytes. This is still too large for an IBM PC. However, KFIELD
+also contains
+
+ char encap[STRING_MAX]; /* encapsulator */
+
+and that field is only rarely used, so by dynamically allocating it
+when needed, we can reduce the KFIELD node storage by 256 - 4 = 252
+bytes, reducing sizeof(FIELD) to 80 bytes. For book.idx, we then need
+80*2531 = 202480 bytes, and that should be small enough to run on the
+PC.
+
+encap is used in genind.c, scanid.c, and sortid.c, and defined in
+mkind.h.
+
+We can handle dynamic allocation of af[] and sf[] three ways: (1)
+initialize them both to (char*)NULL, then allocate space as needed,
+(2) initialize them both to calloc(1), and (3) initialize them both to
+a constant empty string, "". MakeIndex makes many references to the
+first character (*af[i] or af[i][0]), the first scheme would require
+many changes to avoid dereferencing NULL pointers. The second scheme
+would not have this problem, but would require a lot of overhead in
+malloc'ing 1-character blocks. The third scheme seems the best
+choice, and requires few changes; no free() or realloc() calls are
+made by MakeIndex, so we need take no precautions about attempting to
+free or reallocate constant string storage.
+
+Examination of the code in genind.c, scanid.c, and sortid.c which
+references af[] and sf[] shows that changes are needed only in
+scanid.c, where we introduce a new function, make_string(), to handle
+the dynamic allocation of strings when needed. Similarly, of the
+encap[] uses in genind.c, scanid.c, and sortid.c, only scanid.c needs
+changes. The definition of struct KFIELD in mkind.h must be updated
+so that af, sf, and encap become pointers to strings, rather than
+arrays of characters.
+
+
diff --git a/indexing/makeindex/src/RCS/README,v b/indexing/makeindex/src/RCS/README,v
new file mode 100644
index 0000000000..910acbd270
--- /dev/null
+++ b/indexing/makeindex/src/RCS/README,v
@@ -0,0 +1,302 @@
+head 1.2;
+access;
+symbols;
+locks
+ beebe:1.2; strict;
+comment @# @;
+
+
+1.2
+date 93.06.04.18.29.20; author beebe; state Exp;
+branches;
+next 1.1;
+
+1.1
+date 93.06.04.18.29.04; author beebe; state Exp;
+branches;
+next ;
+
+
+desc
+@@
+
+
+1.2
+log
+@Update list of systems with successful tests.
+@
+text
+@% /u/sy/beebe/tex/makeindex/2-12/makeindex/src/README, Wed May 26 11:25:46 1993
+% Edit by Nelson H. F. Beebe <beebe@@plot79.math.utah.edu>
+=================================================================
+= As of the release of MakeIndex version 2.9, the original
+= author, Pehong Chen, is no longer able to maintain it, and is
+= inaccessible via electronic mail. The maintenance job has been
+= taken over for the TeX User's Group by
+=
+= Nelson H. F. Beebe
+= Center for Scientific Computing
+= Department of Mathematics
+= University of Utah
+= Salt Lake City, UT 84112
+= USA
+= Tel: +1 801 581 5254
+= FAX: +1 801 581 4148
+= Email: <beebe@@math.utah.edu>
+=
+= to whom reports of problems, ports to new environments, and
+= general correspondence about MakeIndex, should be addressed.
+=================================================================
+
+
+==================
+Building MakeIndex
+==================
+
+Makefiles for numerous systems are provided in the distribution
+as the files makefile.*; select the appropriate one, and copy it
+to Makefile. For systems that lack a suitable make
+implementation, command files (*.bat and *.com) are provided.
+
+In many cases, once the makefile has been selected, you should be
+able to do
+
+ make
+ (cd ../test; make)
+
+and if the acceptance tests in that second step all pass (there
+should be no output from any of the files differences, except on
+VAX VMS, where a couple of lines differing only in letter case,
+are expected), then on many UNIX systems, you may be able to do
+
+ make install
+
+to install the executable and manual pages on your system.
+
+For version 2.12, the code has been updated to support compilation
+with numerous C++ compilers. No features of the C++ language are used
+that do not also exist in C, but the stricter compile-time checking
+provided by C++ compilers provides additional confidence in the code.
+Thanks go to P. J. Plauger for his efforts in the ANSI/ISO Standard C
+and C++ environments, and for promoting the idea of using C++
+compilers for C code development.
+
+If you have a C++ compiler, please try a build of MakeIndex with a
+command like (select the one that corresponds to the name of your C++
+compiler)
+
+ make CC=CC
+ make CC=xlC
+ make CC=g++
+
+Any problems with C++ compilations should be reported back to the
+address above.
+
+Before doing so however, check that BINDIR and MANDIR are set to
+your local conventions (you can override the values in the
+Makefile by setting them on the command-line), and also verify
+that you do not have a brain-damaged install implementation that
+either requires root privileges to run (e.g. IBM AIX), or moves
+(instead of copies) files (e.g. Stardent or DEC ULTRIX). In the
+latter case, you might be able to instead do
+
+ make cp-install
+
+If you want to undo the installation,
+
+ make uninstall
+
+should work.
+
+There are additional documentation files in ../doc that you may
+want to install manually (Emacs info, local help systems, VAX VMS
+help).
+
+
+====================
+Compilation Problems
+====================
+
+The standardization of the C language by ANSI X3.159-1989
+Programming Language--C (December 15, 1989), and ISO C 1990, has
+resulted in C implementations gradually being adapted to conform
+to the requirements of the Standard, but released for use before
+Standard conformance has been reached. For a lot of C code, this
+affects several main areas:
+
+ (1) system header files, and what symbols they define
+ (2) function prototype declarations
+ (3) new preprocessor statements, and more
+ precisely-defined preprocessor behavior
+ (4) new features introduced by Standard C (const,
+ adjacent string concatenation, new style function
+ definitions, new string escape sequences, trigraphs,
+ new data types)
+
+MakeIndex has successfully compiled and run on many different
+operating systems and C implementations, but until Standard C
+becomes uniformly implemented, the first two above are the most
+troublesome.
+
+The code in MakeIndex is written to conform to Standard C, which
+is distinguished by the preprocessor symbol __STDC__ being
+permanently defined to a non-zero value. Unfortunately, some
+implementations define this symbol without having
+Standard-conforming header files, or without accepting some of
+the new language features.
+
+In MakeIndex, function definitions are done in the old Kernighan and
+Ritchie style in a pre-Standard C environment, but in Standard C and
+C++ style if __STDC__ or __cplusplus are defined.
+
+All functions referenced are declared by function prototype
+declarations of the form
+
+static void check_idx ARGS((char *fn,int open_fn));
+
+where ARGS is defined in mkind.h to expand such a declaration to
+
+static void check_idx (char *fn,int open_fn);
+
+or
+
+static void check_idx ();
+
+depending on whether the compiler supports function prototype
+declarations or not. If you get syntax errors from the new
+style, you may need to revert to the old style by introducing a
+
+#define STDC_PROTOTYPES 0
+
+statement in the appropriate section of mkind.h. Some compilers
+partly support the function prototypes, but without variable
+names; use the old-style for them, and complain to your compiler
+supplier.
+
+When STDC_PROTOTYPES is non-zero, it is assumed that the Standard
+C type modifier "const" is recognized; if your compiler complains
+about it, add a
+
+#define const
+
+definition in mkind.h, or use a compile-time option -Dconst=;
+either of these make it expand to an empty string, so the
+compiler doesn't see it.
+
+Standard C specifies the data types of all library functions and
+their arguments, and the system header files are required to
+declare them appropriately. Nevertheless, some implementations
+have a few erroneous declarations in the header files and still
+claim to be Standard conforming (by defining the symbol __STDC__
+to a non-zero value). On such systems, the extra compile-time
+type checking provided by function prototype declarations may
+raise compilation errors, and it may be necessary to adjust
+declarations in any of the files that use the ARGS macro
+(genind.c, mkind.c, mkind.h, qsort.c, scanid.c, scanst.c, and
+sortid.c) to make the code conform to the local implementation's
+erroneous declarations.
+
+Numerous external variables and functions in MakeIndex require
+long names (at least 12 unique characters). For older systems
+that do not support long names, make sure the symbol SHORTNAMES
+is defined to a non-zero value in mkind.h; this is already done
+for supported systems that need it. Standard C requires
+uniqueness in the first 6 characters of external names, WITHOUT
+distinction between upper- and lower-case letters, so
+implementations that do not allow long external names are NOT in
+violation of the Standard.
+
+If you get compiler warnings about conversion of integers to
+pointers, or find that rindex() or index() cannot be unresolved
+by the linker, then check the settings in mkind.h. The default
+is to use the Standard C functions strchr() and strrchr(), but on
+a few non-conforming systems, to remap these names to index() and
+rindex() instead. Any other integer-to-pointer conversion
+warnings are likely to be traced to missing function prototype
+declarations, which is either because of an omission in system
+header files, or because the MakeIndex declaration in one of its
+source files was not selected during the preprocessing step.
+When the MakeIndex source code is compiled correctly, EVERY
+function used by MakeIndex will have been declared in a function
+prototype prior to its first use.
+
+
+======================
+VAX VMS Considerations
+======================
+
+Different versions of VAX VMS C have used different
+interpretations of the arguments to return() and exit()
+statements. The convention on UNIX and many other systems is
+that a 0 value denotes success, and a non-zero value, failure.
+The EXIT() macro in mkind.h hides the remapping of this value for
+VAX VMS; for other systems, it calls exit() directly.
+
+For VAX VMS, MakeIndex should be declared to be a foreign command
+symbol in a system-wide, or user, startup file that is executed
+at each login. Here is an example:
+
+$ makeindex :== $public$disk:[beebe.MakeIndex.src]makeindex.exe
+
+The leading dollar sign identifies this as a foreign command
+symbol, and must be followed by an ABSOLUTE file specification
+for the executable program; this regrettably makes it site
+dependent, and the definitions in ../test/vmsdiff.com and
+elsewhere must be adjusted accordingly.
+
+The symbol SW_PREFIX in mkind.h can be redefined from '-' to '/'
+for those VAX VMS sites that prefer to retain VMS-style
+command-line options; the default value is '-' on all systems.
+This redefinition can be done on the command line, or by changing
+the setting in mkind.h.
+
+
+===============
+Machines Tested
+===============
+
+Here is a list of machines, operating systems, and compilers under
+which MakeIndex 2.12 has been successfully tested. Convenience targets
+in the Makefile provide support for them on UNIX. Command files are
+provided for MS DOS and VAX VMS.
+
+------------------------------------------------------------------------
+Machine O/S Compiler(s)
+------------------------------------------------------------------------
+
+DEC Alpha 3000/500X OSF 1.2 cc, c89, cxx
+
+DECstation 3100 ULTRIX 4.2 and 4.3 cc, gcc, g++, lcc
+
+DEC VAX VMS 5.4-2 cc
+
+HP 9000/735 HP-UX 9.01 cc, c89, CC, gcc, g++
+
+HP 9000/850 HP-UX 9.0 cc, c89
+
+IBM 3090/600S-VF AIX 2.1 cc (Metaware High C
+ 2.1t), CC
+
+IBM PS/2 AIX 2.1 cc (Metaware High C
+ 2.2g), CC
+
+IBM RS/6000 AIX 3.2 cc, xlC
+
+MIPS R6000 RISC/os 5.0 cc
+
+NeXT Mach 3.0 cc, Objective C, gcc
+
+Sun SPARCstation SunOS 4.1.3 apcc, cc, CC, gcc, g++
+
+------------------------------------------------------------------------
+@
+
+
+1.1
+log
+@Initial revision
+@
+text
+@d238 3
+d244 2
+@
diff --git a/indexing/makeindex/src/RCS/mkind.h,v b/indexing/makeindex/src/RCS/mkind.h,v
new file mode 100644
index 0000000000..dc864553a7
--- /dev/null
+++ b/indexing/makeindex/src/RCS/mkind.h,v
@@ -0,0 +1,812 @@
+head 1.2;
+access;
+symbols;
+locks
+ beebe:1.2; strict;
+comment @ * @;
+
+
+1.2
+date 93.06.04.21.58.00; author beebe; state Exp;
+branches;
+next 1.1;
+
+1.1
+date 93.06.04.21.03.53; author beebe; state Exp;
+branches;
+next ;
+
+
+desc
+@@
+
+
+1.2
+log
+@Move definitions of R_OK to end of file to avoid conflict with
+system definitions. Change dummy argument R_OK to mode in access().
+@
+text
+@/*
+ *
+ * This file is part of
+ * MakeIndex - A formatter and format independent index processor
+ *
+ * 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
+ *
+ * Author:
+ * Pehong Chen
+ * Chen & Harrison International Systems, Inc.
+ * Palo Alto, California
+ * USA
+ * (phc@@renoir.berkeley.edu or chen@@orc.olivetti.com)
+ *
+ * Contributors:
+ * Please refer to the CONTRIB file that comes with this release
+ * for a list of people who have contributed to this and/or previous
+ * release(s) of MakeIndex.
+ *
+ * All rights reserved by the copyright holders. See the copyright
+ * notice distributed with this software for a complete description of
+ * the conditions under which it is made available.
+ *
+ */
+
+/***********************************************************************
+
+ INSTALLATION NOTES
+ <11-Nov-1989>
+
+ At compile-time (or here, if compile-time definition is not
+ available), set non-zero ONE OS_xxxx operating system flag, and if
+ more than one compiler is available, ONE compiler flag:
+
+ Operating Systems Compiler(s)
+ ================= ===========
+ OS_ATARI
+ OS_BS2000 CCD_2000
+ OS_BSD
+ OS_MVSXA IBM_C370
+ OS_VMCMS IBM_C370
+ OS_PCDOS IBM_PC_MICROSOFT
+ OS_SYSV
+ OS_TOPS20 KCC_20 or PCC_20
+ OS_VAXVMS
+ OS_XENIX
+ ================= ===========
+
+ If no OS_xxxx symbol is defined, OS_BSD is assumed.
+
+ If Standard C prototypes are supported, define the symbol
+ STDC_PROTOTYPES in the appropriate OS_xxxx section below, and insert
+ #include's for the standard system files which define library
+ prototypes. STDC_PROTOTYPES will be defined automatically if
+ __STDC__ is; the latter must be defined by all Standard C conformant
+ implementations.
+
+ All function declarations in MakeIndex are contained at the end of
+ this file. If 185STDC_PROTOTYPES is not selected, then all the standard
+ library functions must be declared explicitly.
+
+ If the host system restricts external names to 6 characters, set
+ SHORTNAMES non-zero in the appropriate OS_xxxx section below.
+
+ Installing MakeIndex under BS2000 requires at least Version 8.5
+ supporting Multiple Public Volume Sets (MPVS). Define WORK in this
+ file to your CATID (default :w:) for temporary files (.ilg, .ind),
+ in case of no MPVS support define WORK to NIL.
+
+*/
+
+/**********************************************************************/
+
+#define STDC (__STDC__ || __cplusplus)
+
+/*
+ * Establish needed operating symbols (defaulting to OS_BSD if none
+ * specified at compile time). If you add one, add it to the check
+ * list at the end of this section, too.
+ */
+
+#ifndef OS_ATARI
+#define OS_ATARI 0
+#endif
+
+#ifndef OS_PCDOS
+#define OS_PCDOS 0
+#endif
+
+#ifndef IBM_PC_MICROSOFT
+#define IBM_PC_MICROSOFT 0
+#endif
+
+#ifndef IBM_PC_TURBO
+#define IBM_PC_TURBO 0
+#endif
+
+#ifdef __TURBOC__
+#define IBM_PC_TURBO 1
+#endif
+
+#ifndef OS_SYSV
+#define OS_SYSV 0
+#endif
+
+#ifndef OS_TOPS20
+#define OS_TOPS20 0
+#endif
+
+#ifndef KCC_20
+#define KCC_20 0
+#endif
+
+#ifndef PCC_20
+#define PCC_20 0
+#endif
+
+#ifndef OS_BSD
+#define OS_BSD 0
+#endif
+
+#ifndef OS_VAXVMS
+#define OS_VAXVMS 0
+#endif
+
+#ifndef IBM_C370
+#define IBM_C370 0
+#endif
+
+#ifndef CCD_2000
+#define CCD_2000 0
+#endif
+
+#if OS_TOPS20
+#if (KCC_20 || PCC_20)
+#else
+#undef PCC_20
+#define PCC_20 1 /* PCC-20 is default for Tops-20 */
+#endif /* KCC_20 || PCC_20) */
+#endif /* OS_TOPS20 */
+
+#ifndef OS_BS2000
+#define OS_BS2000 0
+#endif
+
+#ifndef OS_MVSXA
+#define OS_MVSXA 0
+#endif
+
+#ifndef OS_VMCMS
+#define OS_VMCMS 0
+#endif
+
+#ifndef OS_XENIX
+#define OS_XENIX 0
+#endif
+
+#if (OS_ATARI || OS_BSD || OS_BS2000 || OS_MVSXA || OS_PCDOS || OS_VMCMS)
+#else
+#if (OS_SYSV || OS_TOPS20 || OS_VAXVMS || OS_XENIX)
+#else
+#undef OS_BSD
+#define OS_BSD 1 /* Unix is default operating system */
+#endif
+#endif
+
+#if (OS_MVSXA || OS_VMCMS)
+#undef IBM_C370
+#define IBM_C370 1 /* IBM_C370 is default for OS_MVSXA and OS_VMCMS */
+#endif
+
+#if OS_BS2000
+#undef CCD_2000
+#define CCD_2000 1 /* CCD_2000 is default for OS_BS2000 */
+#endif
+
+#if (CCD_2000 || OS_MVSXA || OS_TOPS20 || OS_VMCMS)
+#define SHORTNAMES 1
+#else
+#define SHORTNAMES 0
+#endif
+
+#define STDC_PROTOTYPES STDC
+
+/**********************************************************************/
+
+#include <stdio.h>
+#include <ctype.h>
+
+#if (CCD_2000 || OS_SYSV || OS_PCDOS || STDC || _AIX || ardent )
+#include <string.h>
+#else
+
+#if (OS_ATARI || OS_BSD || PCC_20 || OS_XENIX)
+#define strchr index /* convert STDC form to old K&R form */
+#define strrchr rindex /* convert STDC form to old K&R form */
+#endif /* (OS_ATARI || OS_BSD || PCC_20 || OS_XENIX) */
+
+#endif /* (CCD_2000 || OS_SYSV || OS_PCDOS || STDC || _AIX || ardent) */
+
+#if OS_PCDOS
+
+#if (IBM_PC_MICROSOFT || IBM_PC_TURBO)
+#include <io.h> /* for function declarations */
+#endif /* (IBM_PC_MICROSOFT || IBM_PC_TURBO) */
+
+#include <stddef.h> /* for function declarations */
+#include <stdlib.h> /* for function declarations */
+#undef STDC_PROTOTYPES
+#define STDC_PROTOTYPES 1 /* so we get full argument
+ type checking */
+#endif /* OS_PCDOS */
+
+#if (OS_VMCMS || OS_MVSXA)
+#include <stdefs.h> /* for function declarations */
+#include <string.h> /* for function declarations */
+#undef STDC_PROTOTYPES
+#define STDC_PROTOTYPES 1 /* so we get full argument
+ type checking */
+#if 0
+#undef __STDC__
+#define __STDC__ 1
+#endif
+#endif /* OS_MVSXA || OS_VMCMS */
+
+#if OS_ATARI
+
+#if ATARI_ST_TURBO
+#define access(fn, mode) 0 /* function not available */
+#endif
+
+#if __GNUC__
+#include <string.h>
+#include <types.h>
+#endif
+
+#undef STDC_PROTOTYPES
+#define STDC_PROTOTYPES 1 /* so we get full argument checking */
+
+#endif /* OS_ATARI */
+
+#if IBM_C370
+#define access(fn, mode) 0 /* function not available */
+#endif
+
+#if CCD_2000 /* function not available */
+#define getenv(P) 0
+#endif /* CCD_2000 */
+
+#if SHORTNAMES
+/*
+ * Provide alternate external names which are unique in the first SIX
+ * characters as required for portability (and Standard C)
+ */
+#define check_all chk_all
+#define check_idx chk_idx
+#define check_mixsym chk_mix
+#define compare_one cmp_one
+#define compare_page cmp_page
+#define compare_string cmp_string
+#define delim_n dlm_n
+#define delim_p dlm_p
+#define delim_r dlm_r
+#define delim_t dlm_t
+#define encap_i ecp_i
+#define encap_p ecp_p
+#define encap_range ecp_range
+#define encap_s ecp_s
+#define group_skip grp_skip
+#define group_type grp_type
+#define idx_aclose idxaclose
+#define idx_actual idxactual
+#define idx_keyword idx_kwd
+#define indent_length ind_length
+#define indent_space ind_space
+#define headings_flag hd_flag
+#define heading_pre hd_pre
+#define heading_suf hd_suf
+#define symhead_pos sym_pos
+#define symhead_neg sym_neg
+#define numhead_pos num_pos
+#define numhead_neg num_neg
+#define process_idx prc_idx
+#define process_precedence prc_pre
+#define range_ptr rng_ptr
+#define scan_alpha_lower scnalw
+#define scan_alpha_upper scnaup
+#define scan_arabic scnarabic
+#define scan_arg1 scna1
+#define scan_arg2 scna2
+#define scan_char scnchr
+#define scan_field scnfld
+#define scan_idx scnidx
+#define scan_key scnkey
+#define scan_no scnno
+#define scan_roman_lower scnrlw
+#define scan_roman_upper scnrup
+#define scan_spec scnspc
+#define scan_string scnstr
+#define scan_style scnsty
+#define setpagelen spg_len
+#define setpage_close spg_close
+#define setpage_open spg_open
+#define suffix_2p suf_2p
+#define suffix_3p suf_3p
+#define suffix_mp suf_mp
+#endif /* SHORTNAMES */
+
+#if OS_VAXVMS
+#define EXIT(code) exit( ((code) == 0) ? 1 : (1 << 28) + 2 )
+#else /* NOT OS_VAXVMS */
+#define EXIT exit
+#endif /* OS_VAXVMS */
+
+#undef TRUE
+#define TRUE 1
+
+#undef FALSE
+#define FALSE 0
+
+#undef NUL
+#define NUL '\0'
+
+#undef NIL
+#define NIL ""
+
+#define TAB '\t'
+#define LFD '\n'
+#define SPC ' '
+#define LSQ '['
+#define RSQ ']'
+#define BSH '\\'
+
+#if OS_ATARI
+#define ENV_SEPAR ';'
+#define DIR_DELIM '\\'
+#endif /* OS_ATARI */
+
+#if (OS_BSD || OS_SYSV || OS_XENIX)
+#define ENV_SEPAR ':'
+#define DIR_DELIM '/'
+#endif /* (OS_BSD || OS_SYSV || OS_XENIX)*/
+
+#if OS_BS2000
+#define ENV_SEPAR '#'
+#define DIR_DELIM '$'
+#endif /* OS_BS2000 */
+
+#if (OS_MVSXA || OS_VMCMS)
+#define ENV_SEPAR '.'
+#define DIR_DELIM '.'
+#endif /* OS_MVSXA || OS_VMCMS */
+
+#if OS_PCDOS
+#define ENV_SEPAR ';'
+#define DIR_DELIM '\\'
+#endif /* OS_PCDOS */
+
+#if OS_TOPS20
+#define ENV_SEPAR ','
+#define DIR_DELIM ':'
+#endif /* OS_TOPS20 */
+
+#if OS_BSD
+#define ENV_SEPAR ':'
+#define DIR_DELIM '/'
+#endif /* OS_BSD */
+
+#if OS_VAXVMS
+#define ENV_SEPAR ',' /* In fact these aren't used */
+#define DIR_DELIM ':'
+#endif /* OS_VAXVMS */
+
+#ifndef SW_PREFIX /* can override at compile time */
+#define SW_PREFIX '-'
+#endif
+
+#define EXT_DELIM '.'
+#define ROMAN_SIGN '*'
+#define EVEN "even"
+#define ODD "odd"
+#define ANY "any"
+
+#define GET_CHAR getc
+
+#if (CCD_2000 || OS_MVSXA)
+#define TOASCII(i) (char)((i) + '0')
+#else
+#define TOASCII(i) (char)((i) + 48)
+#endif /* (CCD_2000 || OS_MVSXA) */
+
+/* NB: The typecasts here are CRITICAL for correct sorting of entries
+ that use characters in the range 128..255! */
+#define TOLOWER(C) (isupper((unsigned char)(C)) ? \
+ (unsigned char)tolower((unsigned char)(C)) : (unsigned char)(C))
+#define TOUPPER(C) (isupper((unsigned char)(C)) ? \
+ (unsigned char)(C) : (unsigned char)toupper((unsigned char)(C)))
+
+#define STREQ(A, B) (strcmp(A, B) == 0)
+#define STRNEQ(A, B) (strcmp(A, B) != 0)
+
+#define MESSAGE(F, S) { \
+ if (verbose) \
+ fprintf(stderr, F, S); \
+ fprintf(ilg_fp, F, S); \
+}
+
+#define FATAL(F, S) { \
+ fprintf(stderr, F, S); \
+ fprintf(stderr, USAGE, pgm_fn); \
+ EXIT(1); \
+}
+
+#define FATAL2(F, D1, D2) { \
+ fprintf(stderr, F, D1, D2); \
+ fprintf(stderr, USAGE, pgm_fn); \
+ EXIT(1); \
+}
+
+#if OS_PCDOS /* open file in binary mode */
+#define OPEN_IN_B(FP) fopen(FP, "rb")
+#endif
+
+#define OPEN_IN(FP) fopen(FP, "r")
+#define OPEN_OUT(FP) fopen(FP, "w")
+#define CLOSE(FP) fclose(FP)
+
+#if (CCD_2000 || OS_MVSXA)
+#define ASCII 1
+#define ISDIGIT(C) isdigit(C)
+#define ISSYMBOL(C) (! (isdigit(C) || isalpha(C) || iscntrl(C) || C == SPC))
+#else
+#define ISDIGIT(C) ('0' <= C && C <= '9')
+#define ISSYMBOL(C) (('!' <= C && C <= '@@') || \
+ ('[' <= C && C <= '`') || \
+ ('{' <= C && C <= '~'))
+#endif /* (CCD_2000 || OS_MVSXA) */
+
+/*====================================================================
+Many arrays in MakeIndex are dimensioned [xxx_MAX], where the xxx_MAX
+values are defined below. The use of each of these is described in
+comments. However, no run-time check is made to ensure that these are
+consistent, or reasonable! Therefore, change them only with great
+care.
+
+The array sizes should be made generously large: there are a great
+many uses of strings in MakeIndex with the strxxx() and sprintf()
+functions where no checking is done for adequate target storage sizes.
+Although some input checking is done to avoid this possibility, it is
+highly likely that there are still several places where storage
+violations are possible, with core dumps, or worse, incorrect output,
+ensuing.
+======================================================================*/
+
+#define ARABIC_MAX 5 /* maximum digits in an Arabic page */
+ /* number field */
+
+#define ARGUMENT_MAX 1024 /* maximum length of sort or actual key */
+ /* in index entry */
+
+#define ARRAY_MAX 1024 /* maximum length of constant values in */
+ /* style file */
+
+#define FIELD_MAX 3 /* maximum levels of index entries (item, */
+ /* subitem, subsubitem); cannot be */
+ /* increased beyond 3 without */
+ /* significant design changes (no field */
+ /* names are known beyond 3 levels) */
+
+#ifdef LINE_MAX /* IBM RS/6000 AIX has this in <sys/limits.h> */
+#undef LINE_MAX
+#endif
+#define LINE_MAX 72 /* maximum output line length (longer */
+ /* ones wrap if possible) */
+
+#define NUMBER_MAX 16 /* maximum digits in a Roman or Arabic */
+ /* page number */
+ /* (MAX(ARABIC_MAX,ROMAN_MAX)) */
+
+#define PAGEFIELD_MAX 10 /* maximum fields in a composite page */
+ /* number */
+
+#define PAGETYPE_MAX 5 /* fixed at 5; see use in scanst.c */
+
+#define ROMAN_MAX 16 /* maximum length of Roman page number */
+ /* field */
+
+#define STRING_MAX 256 /* maximum length of host filename */
+
+/*====================================================================*/
+
+#define VERSION "portable version 2.12 [26-May-1993]"
+
+#if 0
+#define VERSION "portable version 2.11 [19-Oct-1991]"
+#define VERSION "portable version 2.10 [05-Jul-1991]"
+#define VERSION "portable version 2.9.1 [21-Jun-1990]"
+#define VERSION "portable version 2.9 [13-Dec-1989]"
+#define VERSION "portable version 2.8 [11-Nov-1989]"
+#define VERSION "portable version 2.7 [01-Oct-1988]"
+#define VERSION "portable version 2.6 [14-Jul-1988]"
+#define VERSION "portable version 2.5 [14-Apr-1988]"
+#define VERSION "portable version 2.4 [20-Mar-1988]"
+#define VERSION "portable version 2.3 [20-Jan-1988]"
+#define VERSION "version 2.2 [29-May-1987]"
+#endif
+
+#define PUT_VERSION { \
+ MESSAGE("This is %s, ", pgm_fn); \
+ MESSAGE("%s.\n", VERSION); \
+ need_version = FALSE; \
+}
+
+#define USAGE \
+ "Usage: %s [-ilqrcg] [-s sty] [-o ind] [-t log] [-p num] [idx0 idx1 ...]\n"
+
+#define STYLE_PATH "INDEXSTYLE" /* environment variable defining search */
+ /* path for style files */
+#define INDEX_IDX ".idx"
+#define INDEX_ILG ".ilg"
+#define INDEX_IND ".ind"
+#define INDEX_STY ".mst"
+
+#if OS_VAXVMS
+#define INDEX_LOG ".lis"
+#else
+#define INDEX_LOG ".log"
+#endif
+
+#if OS_BS2000 /* Define WORK disk */
+#define WORK ":w:"
+#define CATID ':'
+#endif /* OS_BS2000 */
+
+#define EMPTY -9999
+#define ROML 0
+#define ROMU 1
+#define ARAB 2
+#define ALPL 3
+#define ALPU 4
+#define DUPLICATE 9999
+
+#define SYMBOL -1
+#define ALPHA -2
+
+#define GERMAN 0
+
+typedef struct KFIELD
+{
+ char *sf[FIELD_MAX]; /* sort key */
+ char *af[FIELD_MAX]; /* actual key */
+ int group; /* key group */
+ char lpg[NUMBER_MAX]; /* literal page */
+ short npg[PAGEFIELD_MAX]; /* page field array */
+ short count; /* page field count */
+ short type; /* page number type */
+ char *encap; /* encapsulator */
+ char *fn; /* input filename */
+ int lc; /* line number */
+} FIELD, *FIELD_PTR;
+
+typedef struct KNODE
+{
+ FIELD data;
+ struct KNODE *next;
+} NODE, *NODE_PTR;
+
+extern int letter_ordering;
+extern int compress_blanks;
+extern int init_page;
+extern int merge_page;
+extern int even_odd;
+extern int verbose;
+extern int german_sort;
+
+extern char idx_keyword[ARRAY_MAX];
+extern char idx_aopen;
+extern char idx_aclose;
+extern char idx_level;
+extern char idx_ropen;
+extern char idx_rclose;
+extern char idx_quote;
+extern char idx_actual;
+extern char idx_encap;
+extern char idx_escape;
+
+extern char page_comp[ARRAY_MAX];
+extern int page_offset[PAGETYPE_MAX];
+
+extern char preamble[ARRAY_MAX];
+extern char postamble[ARRAY_MAX];
+extern char setpage_open[ARRAY_MAX];
+extern char setpage_close[ARRAY_MAX];
+extern char group_skip[ARRAY_MAX];
+extern int headings_flag;
+extern char heading_pre[ARRAY_MAX];
+extern char heading_suf[ARRAY_MAX];
+extern char symhead_pos[ARRAY_MAX];
+extern char symhead_neg[ARRAY_MAX];
+extern char numhead_pos[ARRAY_MAX];
+extern char numhead_neg[ARRAY_MAX];
+extern int prelen;
+extern int postlen;
+extern int skiplen;
+extern int headprelen;
+extern int headsuflen;
+extern int setpagelen;
+
+extern char item_r[FIELD_MAX][ARRAY_MAX];
+extern char item_u[FIELD_MAX][ARRAY_MAX];
+extern char item_x[FIELD_MAX][ARRAY_MAX];
+extern int ilen_r[FIELD_MAX];
+extern int ilen_u[FIELD_MAX];
+extern int ilen_x[FIELD_MAX];
+
+extern char delim_p[FIELD_MAX][ARRAY_MAX];
+extern char delim_n[ARRAY_MAX];
+extern char delim_r[ARRAY_MAX];
+extern char delim_t[ARRAY_MAX];
+
+extern char suffix_2p[ARRAY_MAX];
+extern char suffix_3p[ARRAY_MAX];
+extern char suffix_mp[ARRAY_MAX];
+
+extern char encap_p[ARRAY_MAX];
+extern char encap_i[ARRAY_MAX];
+extern char encap_s[ARRAY_MAX];
+
+extern int linemax;
+extern char indent_space[ARRAY_MAX];
+extern int indent_length;
+
+extern FILE *idx_fp;
+extern FILE *sty_fp;
+extern FILE *ind_fp;
+extern FILE *ilg_fp;
+
+#if OS_BS2000
+extern FILE *widx_fp;
+extern char widx_fn[STRING_MAX + 5];
+#endif /* OS_BS2000 */
+
+extern char *idx_fn;
+extern char *pgm_fn;
+extern char *ind_fn;
+extern char *ilg_fn;
+
+#ifndef MKIND_C
+extern char sty_fn[];
+extern char ind[];
+extern char ilg[];
+extern char pageno[];
+
+#ifdef DEBUG
+extern long totmem;
+#endif /* DEBUG */
+
+#endif
+
+extern FIELD_PTR *idx_key;
+extern NODE_PTR head;
+extern NODE_PTR tail;
+
+extern int idx_dot;
+extern int idx_tt;
+extern int idx_gt;
+extern int idx_et;
+extern int idx_dc;
+
+#define DOT "."
+#define DOT_MAX 1000
+#define CMP_MAX 1500
+
+#define IDX_DOT(MAX) { \
+ idx_dot = TRUE; \
+ if (idx_dc++ == 0) { \
+ if (verbose) \
+ fprintf(stderr, DOT); \
+ fprintf(ilg_fp, DOT); \
+ } \
+ if (idx_dc == MAX) \
+ idx_dc = 0; \
+}
+
+#define ALL_DONE { \
+ if (fn_no > 0) { \
+ if (verbose) \
+fprintf(stderr, \
+ "Overall %d files read (%d entries accepted, %d rejected).\n", \
+ fn_no+1, idx_gt, idx_et); \
+fprintf(ilg_fp, \
+ "Overall %d files read (%d entries accepted, %d rejected).\n", \
+ fn_no+1, idx_gt, idx_et); \
+ } \
+}
+
+#define DONE(A, B, C, D) { \
+ if (verbose) \
+ fprintf(stderr, "done (%d %s, %d %s).\n", (A), B, C, D); \
+ fprintf(ilg_fp, "done (%d %s, %d %s).\n", (A), B, C, D); \
+}
+
+#if STDC_PROTOTYPES
+#define ARGS(arg_list) arg_list
+#define VOIDP void*
+#define VOID_ARG void
+#else
+#define ARGS(arg_list) ()
+#define const
+#define VOIDP char*
+#define VOID_ARG
+#endif
+
+extern void gen_ind ARGS((void));
+extern int group_type ARGS((char *str));
+extern int main ARGS((int argc, char **argv));
+extern void qqsort ARGS((char *base, int n, int size,
+ int (*compar)ARGS((char*,char*))));
+extern void scan_idx ARGS((void));
+extern void scan_sty ARGS((void));
+extern void sort_idx ARGS((void));
+extern int strtoint ARGS((char *str));
+
+#if STDC
+#include <stdlib.h>
+#undef strchr
+#undef strrchr
+#if __NeXT__
+int access ARGS((const char *, int));
+#else
+#include <unistd.h>
+#endif
+#else
+/* Miscellaneous standard library routines */
+int access ARGS((const char *, int));
+VOIDP calloc ARGS((size_t nitems,size_t size));
+
+#if CCD_2000 /* function not available */
+#define getenv(P) 0
+#else
+char *getenv ARGS((const char *name));
+#endif
+
+VOIDP malloc ARGS((size_t size));
+char *strchr ARGS((const char *s,int c));
+char *strrchr ARGS((const char *s,int c));
+#endif /* __STDC__ */
+
+#if PCC_20
+#define R_OK 0 /* PCC-20 access(file,mode) */
+#endif /* only understands mode=0 */
+
+#ifndef R_OK
+#define R_OK 4 /* only symbol from sys/file.h */
+#endif
+@
+
+
+1.1
+log
+@Initial revision
+@
+text
+@d231 1
+a231 1
+#define access(fn, R_OK) 0 /* function not available */
+d245 1
+a245 1
+#define access(fn, R_OK) 0 /* function not available */
+a251 4
+#if PCC_20
+#define R_OK 0 /* PCC-20 access(file,mode) */
+#endif /* only understands mode=0 */
+
+a316 4
+#ifndef R_OK
+#define R_OK 4 /* only symbol from sys/file.h */
+#endif
+
+d750 8
+@
diff --git a/indexing/makeindex/src/README b/indexing/makeindex/src/README
new file mode 100644
index 0000000000..4b3413ec93
--- /dev/null
+++ b/indexing/makeindex/src/README
@@ -0,0 +1,263 @@
+% /u/sy/beebe/tex/makeindex/2-12/makeindex/src/README, Wed May 26 11:25:46 1993
+% Edit by Nelson H. F. Beebe <beebe@plot79.math.utah.edu>
+=================================================================
+= As of the release of MakeIndex version 2.9, the original
+= author, Pehong Chen, is no longer able to maintain it, and is
+= inaccessible via electronic mail. The maintenance job has been
+= taken over for the TeX User's Group by
+=
+= Nelson H. F. Beebe
+= Center for Scientific Computing
+= Department of Mathematics
+= University of Utah
+= Salt Lake City, UT 84112
+= USA
+= Tel: +1 801 581 5254
+= FAX: +1 801 581 4148
+= Email: <beebe@math.utah.edu>
+=
+= to whom reports of problems, ports to new environments, and
+= general correspondence about MakeIndex, should be addressed.
+=================================================================
+
+
+==================
+Building MakeIndex
+==================
+
+Makefiles for numerous systems are provided in the distribution
+as the files makefile.*; select the appropriate one, and copy it
+to Makefile. For systems that lack a suitable make
+implementation, command files (*.bat and *.com) are provided.
+
+In many cases, once the makefile has been selected, you should be
+able to do
+
+ make
+ (cd ../test; make)
+
+and if the acceptance tests in that second step all pass (there
+should be no output from any of the files differences, except on
+VAX VMS, where a couple of lines differing only in letter case,
+are expected), then on many UNIX systems, you may be able to do
+
+ make install
+
+to install the executable and manual pages on your system.
+
+For version 2.12, the code has been updated to support compilation
+with numerous C++ compilers. No features of the C++ language are used
+that do not also exist in C, but the stricter compile-time checking
+provided by C++ compilers provides additional confidence in the code.
+Thanks go to P. J. Plauger for his efforts in the ANSI/ISO Standard C
+and C++ environments, and for promoting the idea of using C++
+compilers for C code development.
+
+If you have a C++ compiler, please try a build of MakeIndex with a
+command like (select the one that corresponds to the name of your C++
+compiler)
+
+ make CC=CC
+ make CC=xlC
+ make CC=g++
+
+Any problems with C++ compilations should be reported back to the
+address above.
+
+Before doing so however, check that BINDIR and MANDIR are set to
+your local conventions (you can override the values in the
+Makefile by setting them on the command-line), and also verify
+that you do not have a brain-damaged install implementation that
+either requires root privileges to run (e.g. IBM AIX), or moves
+(instead of copies) files (e.g. Stardent or DEC ULTRIX). In the
+latter case, you might be able to instead do
+
+ make cp-install
+
+If you want to undo the installation,
+
+ make uninstall
+
+should work.
+
+There are additional documentation files in ../doc that you may
+want to install manually (Emacs info, local help systems, VAX VMS
+help).
+
+
+====================
+Compilation Problems
+====================
+
+The standardization of the C language by ANSI X3.159-1989
+Programming Language--C (December 15, 1989), and ISO C 1990, has
+resulted in C implementations gradually being adapted to conform
+to the requirements of the Standard, but released for use before
+Standard conformance has been reached. For a lot of C code, this
+affects several main areas:
+
+ (1) system header files, and what symbols they define
+ (2) function prototype declarations
+ (3) new preprocessor statements, and more
+ precisely-defined preprocessor behavior
+ (4) new features introduced by Standard C (const,
+ adjacent string concatenation, new style function
+ definitions, new string escape sequences, trigraphs,
+ new data types)
+
+MakeIndex has successfully compiled and run on many different
+operating systems and C implementations, but until Standard C
+becomes uniformly implemented, the first two above are the most
+troublesome.
+
+The code in MakeIndex is written to conform to Standard C, which
+is distinguished by the preprocessor symbol __STDC__ being
+permanently defined to a non-zero value. Unfortunately, some
+implementations define this symbol without having
+Standard-conforming header files, or without accepting some of
+the new language features.
+
+In MakeIndex, function definitions are done in the old Kernighan and
+Ritchie style in a pre-Standard C environment, but in Standard C and
+C++ style if __STDC__ or __cplusplus are defined.
+
+All functions referenced are declared by function prototype
+declarations of the form
+
+static void check_idx ARGS((char *fn,int open_fn));
+
+where ARGS is defined in mkind.h to expand such a declaration to
+
+static void check_idx (char *fn,int open_fn);
+
+or
+
+static void check_idx ();
+
+depending on whether the compiler supports function prototype
+declarations or not. If you get syntax errors from the new
+style, you may need to revert to the old style by introducing a
+
+#define STDC_PROTOTYPES 0
+
+statement in the appropriate section of mkind.h. Some compilers
+partly support the function prototypes, but without variable
+names; use the old-style for them, and complain to your compiler
+supplier.
+
+When STDC_PROTOTYPES is non-zero, it is assumed that the Standard
+C type modifier "const" is recognized; if your compiler complains
+about it, add a
+
+#define const
+
+definition in mkind.h, or use a compile-time option -Dconst=;
+either of these make it expand to an empty string, so the
+compiler doesn't see it.
+
+Standard C specifies the data types of all library functions and
+their arguments, and the system header files are required to
+declare them appropriately. Nevertheless, some implementations
+have a few erroneous declarations in the header files and still
+claim to be Standard conforming (by defining the symbol __STDC__
+to a non-zero value). On such systems, the extra compile-time
+type checking provided by function prototype declarations may
+raise compilation errors, and it may be necessary to adjust
+declarations in any of the files that use the ARGS macro
+(genind.c, mkind.c, mkind.h, qsort.c, scanid.c, scanst.c, and
+sortid.c) to make the code conform to the local implementation's
+erroneous declarations.
+
+Numerous external variables and functions in MakeIndex require
+long names (at least 12 unique characters). For older systems
+that do not support long names, make sure the symbol SHORTNAMES
+is defined to a non-zero value in mkind.h; this is already done
+for supported systems that need it. Standard C requires
+uniqueness in the first 6 characters of external names, WITHOUT
+distinction between upper- and lower-case letters, so
+implementations that do not allow long external names are NOT in
+violation of the Standard.
+
+If you get compiler warnings about conversion of integers to
+pointers, or find that rindex() or index() cannot be unresolved
+by the linker, then check the settings in mkind.h. The default
+is to use the Standard C functions strchr() and strrchr(), but on
+a few non-conforming systems, to remap these names to index() and
+rindex() instead. Any other integer-to-pointer conversion
+warnings are likely to be traced to missing function prototype
+declarations, which is either because of an omission in system
+header files, or because the MakeIndex declaration in one of its
+source files was not selected during the preprocessing step.
+When the MakeIndex source code is compiled correctly, EVERY
+function used by MakeIndex will have been declared in a function
+prototype prior to its first use.
+
+
+======================
+VAX VMS Considerations
+======================
+
+Different versions of VAX VMS C have used different
+interpretations of the arguments to return() and exit()
+statements. The convention on UNIX and many other systems is
+that a 0 value denotes success, and a non-zero value, failure.
+The EXIT() macro in mkind.h hides the remapping of this value for
+VAX VMS; for other systems, it calls exit() directly.
+
+For VAX VMS, MakeIndex should be declared to be a foreign command
+symbol in a system-wide, or user, startup file that is executed
+at each login. Here is an example:
+
+$ makeindex :== $public$disk:[beebe.MakeIndex.src]makeindex.exe
+
+The leading dollar sign identifies this as a foreign command
+symbol, and must be followed by an ABSOLUTE file specification
+for the executable program; this regrettably makes it site
+dependent, and the definitions in ../test/vmsdiff.com and
+elsewhere must be adjusted accordingly.
+
+The symbol SW_PREFIX in mkind.h can be redefined from '-' to '/'
+for those VAX VMS sites that prefer to retain VMS-style
+command-line options; the default value is '-' on all systems.
+This redefinition can be done on the command line, or by changing
+the setting in mkind.h.
+
+
+===============
+Machines Tested
+===============
+
+Here is a list of machines, operating systems, and compilers under
+which MakeIndex 2.12 has been successfully tested. Convenience targets
+in the Makefile provide support for them on UNIX. Command files are
+provided for MS DOS and VAX VMS.
+
+------------------------------------------------------------------------
+Machine O/S Compiler(s)
+------------------------------------------------------------------------
+
+DEC Alpha 3000/500X OSF 1.2 cc, c89, cxx
+
+DECstation 3100 ULTRIX 4.2 and 4.3 cc, gcc, g++, lcc
+
+DEC VAX VMS 5.4-2 cc
+
+HP 9000/735 HP-UX 9.01 cc, c89, CC, gcc, g++
+
+HP 9000/850 HP-UX 9.0 cc, c89
+
+IBM 3090/600S-VF AIX 2.1 cc (Metaware High C
+ 2.1t), CC
+
+IBM PS/2 AIX 2.1 cc (Metaware High C
+ 2.2g), CC
+
+IBM RS/6000 AIX 3.2 cc, xlC
+
+MIPS R6000 RISC/os 5.0 cc
+
+NeXT Mach 3.0 cc, Objective C, gcc
+
+Sun SPARCstation SunOS 4.1.3 apcc, cc, CC, gcc, g++
+
+------------------------------------------------------------------------
diff --git a/indexing/makeindex/src/genind.c b/indexing/makeindex/src/genind.c
new file mode 100644
index 0000000000..3d176cec0f
--- /dev/null
+++ b/indexing/makeindex/src/genind.c
@@ -0,0 +1,477 @@
+/*
+ *
+ * This file is part of
+ * MakeIndex - A formatter and format independent index processor
+ *
+ * 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
+ *
+ * Author:
+ * Pehong Chen
+ * Chen & Harrison International Systems, Inc.
+ * Palo Alto, California
+ * USA
+ * (phc@renoir.berkeley.edu or chen@orc.olivetti.com)
+ *
+ * Contributors:
+ * Please refer to the CONTRIB file that comes with this release
+ * for a list of people who have contributed to this and/or previous
+ * release(s) of MakeIndex.
+ *
+ * All rights reserved by the copyright holders. See the copyright
+ * notice distributed with this software for a complete description of
+ * the conditions under which it is made available.
+ *
+ */
+
+#include "mkind.h"
+#include "genind.h"
+
+#if sun /* avoid conflict with symbol in */
+ /* /usr/lang/SC1.0/include/CC/stdlib.h */
+#define end the_end
+#endif
+
+static FIELD_PTR curr = NULL;
+static FIELD_PTR prev = NULL;
+static FIELD_PTR begin = NULL;
+static FIELD_PTR end = NULL;
+static FIELD_PTR range_ptr;
+static int level = 0;
+static int prev_level = 0;
+static char *encap = NULL;
+static char *prev_encap = NULL;
+static int in_range = FALSE;
+static int encap_range = FALSE;
+static char buff[2 * ARGUMENT_MAX];
+static char line[2 * ARGUMENT_MAX]; /* output buffer */
+static int ind_lc = 0; /* overall line count */
+static int ind_ec = 0; /* erroneous line count */
+static int ind_indent;
+
+static void flush_line ARGS((int print));
+static void insert_page ARGS((void));
+static int make_entry ARGS((int n));
+static void make_item ARGS((char* term));
+static void new_entry ARGS((void));
+static void old_entry ARGS((void));
+static int page_diff ARGS((struct KFIELD *a,struct KFIELD *b));
+static void put_header ARGS((int let));
+static void wrap_line ARGS((int print));
+
+void
+gen_ind(VOID_ARG)
+{
+ int n;
+ int tmp_lc;
+
+ MESSAGE("Generating output file %s...", ind_fn);
+ PUT(preamble);
+ ind_lc += prelen;
+ if (init_page)
+ insert_page();
+
+ /* reset counters for putting out dots */
+ idx_dc = 0;
+ for (n = 0; n < idx_gt; n++) {
+ if (idx_key[n]->type != DUPLICATE)
+ if (make_entry(n)) {
+ IDX_DOT(DOT_MAX);
+ }
+ }
+ tmp_lc = ind_lc;
+ if (in_range) {
+ curr = range_ptr;
+ IND_ERROR("Unmatched range opening operator %c.\n", idx_ropen);
+ }
+ prev = curr;
+ flush_line(TRUE);
+ PUT(delim_t);
+ PUT(postamble);
+ tmp_lc = ind_lc + postlen;
+ if (ind_ec == 1) {
+ DONE(tmp_lc, "lines written", ind_ec, "warning");
+ } else {
+ DONE(tmp_lc, "lines written", ind_ec, "warnings");
+ }
+}
+
+
+static int
+#if STDC
+make_entry(int n)
+#else
+make_entry(n)
+int n;
+#endif
+{
+ int let;
+
+ /* determine current and previous pointer */
+ prev = curr;
+ curr = idx_key[n];
+ /* check if current entry is in range */
+ if ((*curr->encap == idx_ropen) || (*curr->encap == idx_rclose))
+ encap = &(curr->encap[1]);
+ else
+ encap = curr->encap;
+
+ /* determine the current nesting level */
+ if (n == 0) {
+ prev_level = level = 0;
+ let = *curr->sf[0];
+ put_header(let);
+ make_item(NIL);
+ } else {
+ prev_level = level;
+ for (level = 0; level < FIELD_MAX; level++)
+ if (STRNEQ(curr->sf[level], prev->sf[level]) ||
+ STRNEQ(curr->af[level], prev->af[level]))
+ break;
+ if (level < FIELD_MAX)
+ new_entry();
+ else
+ old_entry();
+ }
+
+ if (*curr->encap == idx_ropen)
+ if (in_range) {
+ IND_ERROR("Extra range opening operator %c.\n", idx_ropen);
+ } else {
+ in_range = TRUE;
+ range_ptr = curr;
+ }
+ else if (*curr->encap == idx_rclose)
+ if (in_range) {
+ in_range = FALSE;
+ if (STRNEQ(&(curr->encap[1]), "") &&
+ STRNEQ(prev_encap, &(curr->encap[1]))) {
+IND_ERROR("Range closing operator has an inconsistent encapsulator %s.\n",
+ &(curr->encap[1]));
+ }
+ } else {
+ IND_ERROR("Unmatched range closing operator %c.\n", idx_rclose);
+ }
+ else if ((*curr->encap != NUL) &&
+ STRNEQ(curr->encap, prev_encap) && in_range)
+ IND_ERROR("Inconsistent page encapsulator %s within range.\n",
+ curr->encap);
+ return (1);
+}
+
+
+static void
+#if STDC
+make_item(char *term)
+#else
+make_item(term)
+char *term;
+#endif
+{
+ int i;
+
+ if (level > prev_level) {
+ /* ascending level */
+ if (*curr->af[level] == NUL)
+ sprintf(line, "%s%s%s", term, item_u[level], curr->sf[level]);
+ else
+ sprintf(line, "%s%s%s", term, item_u[level], curr->af[level]);
+ ind_lc += ilen_u[level];
+ } else {
+ /* same or descending level */
+ if (*curr->af[level] == NUL)
+ sprintf(line, "%s%s%s", term, item_r[level], curr->sf[level]);
+ else
+ sprintf(line, "%s%s%s", term, item_r[level], curr->af[level]);
+ ind_lc += ilen_r[level];
+ }
+
+ i = level + 1;
+ while (i < FIELD_MAX && *curr->sf[i] != NUL) {
+ PUT(line);
+ if (*curr->af[i] == NUL)
+ sprintf(line, "%s%s", item_x[i], curr->sf[i]);
+ else
+ sprintf(line, "%s%s", item_x[i], curr->af[i]);
+ ind_lc += ilen_x[i];
+ level = i; /* Added at 2.11 <brosig@gmdzi.gmd.de> */
+ i++;
+ }
+
+ ind_indent = 0;
+ strcat(line, delim_p[level]);
+ SAVE;
+}
+
+
+static void
+new_entry(VOID_ARG)
+{
+ int let;
+ FIELD_PTR ptr;
+
+ if (in_range) {
+ ptr = curr;
+ curr = range_ptr;
+ IND_ERROR("Unmatched range opening operator %c.\n", idx_ropen);
+ in_range = FALSE;
+ curr = ptr;
+ }
+ flush_line(TRUE);
+
+ /* beginning of a new group? */
+
+ if (((curr->group != ALPHA) && (curr->group != prev->group) &&
+ (prev->group == SYMBOL)) ||
+ ((curr->group == ALPHA) &&
+ ((unsigned char)(let = TOLOWER(curr->sf[0][0]))
+ != (TOLOWER(prev->sf[0][0])))) ||
+ (german_sort &&
+ (curr->group != ALPHA) && (prev->group == ALPHA))) {
+ PUT(delim_t);
+ PUT(group_skip);
+ ind_lc += skiplen;
+ /* beginning of a new letter? */
+ put_header(let);
+ make_item(NIL);
+ } else
+ make_item(delim_t);
+}
+
+
+static void
+old_entry(VOID_ARG)
+{
+ int diff;
+
+ /* current entry identical to previous one: append pages */
+ diff = page_diff(end, curr);
+
+ if ((prev->type == curr->type) && (diff != -1) &&
+ (((diff == 0) && (prev_encap != NULL) && STREQ(encap, prev_encap)) ||
+ (merge_page && (diff == 1) &&
+ (prev_encap != NULL) && STREQ(encap, prev_encap)) ||
+ in_range)) {
+ end = curr;
+ /* extract in-range encaps out */
+ if (in_range &&
+ (*curr->encap != NUL) &&
+ (*curr->encap != idx_rclose) &&
+ STRNEQ(curr->encap, prev_encap)) {
+ sprintf(buff, "%s%s%s%s%s", encap_p, curr->encap,
+ encap_i, curr->lpg, encap_s);
+ wrap_line(FALSE);
+ }
+ if (in_range)
+ encap_range = TRUE;
+ } else {
+ flush_line(FALSE);
+ if ((diff == 0) && (prev->type == curr->type)) {
+IND_ERROR(
+"Conflicting entries: multiple encaps for the same page under same key.\n",
+"");
+ } else if (in_range && (prev->type != curr->type)) {
+IND_ERROR(
+"Illegal range formation: starting & ending pages are of different types.\n",
+"");
+ } else if (in_range && (diff == -1)) {
+IND_ERROR(
+"Illegal range formation: starting & ending pages cross chap/sec breaks.\n",
+"");
+ }
+ SAVE;
+ }
+}
+
+
+static int
+#if STDC
+page_diff(FIELD_PTR a,FIELD_PTR b)
+#else
+page_diff(a, b)
+FIELD_PTR a;
+FIELD_PTR b;
+#endif
+{
+ short i;
+
+ if (a->count != b->count)
+ return (-1);
+ for (i = 0; i < a->count - 1; i++)
+ if (a->npg[i] != b->npg[i])
+ return (-1);
+ return (b->npg[b->count - 1] - a->npg[a->count - 1]);
+}
+
+static void
+#if STDC
+put_header(int let)
+#else
+put_header(let)
+int let;
+#endif
+{
+ if (headings_flag)
+ {
+ PUT(heading_pre);
+ ind_lc += headprelen;
+ switch (curr->group)
+ {
+ case SYMBOL:
+ if (headings_flag > 0)
+ {
+ PUT(symhead_pos);
+ }
+ else
+ {
+ PUT(symhead_neg);
+ }
+ break;
+ case ALPHA:
+ if (headings_flag > 0)
+ {
+ let = TOUPPER(let);
+ PUTC(let);
+ }
+ else
+ {
+ let = TOLOWER(let);
+ PUTC(let);
+ }
+ break;
+ default:
+ if (headings_flag > 0)
+ {
+ PUT(numhead_pos);
+ }
+ else
+ {
+ PUT(numhead_neg);
+ }
+ break;
+ }
+ PUT(heading_suf);
+ ind_lc += headsuflen;
+ }
+}
+
+
+/* changes for 2.12 (May 20, 1993) by Julian Reschke (jr@ms.maus.de):
+ Use keywords suffix_2p, suffix_3p or suffix_mp for one, two or
+ multiple page ranges (when defined) */
+
+static void
+#if STDC
+flush_line(int print)
+#else
+flush_line(print)
+int print;
+#endif
+{
+ char tmp[sizeof(buff)];
+
+ if (page_diff(begin, end) != 0)
+ if (encap_range || (page_diff(begin, prev) > (*suffix_2p ? 0 : 1)))
+ {
+ int diff = page_diff(begin, end);
+
+ if ((diff == 1) && *suffix_2p)
+ sprintf(buff, "%s%s", begin->lpg, suffix_2p);
+ else if ((diff == 2) && *suffix_3p)
+ sprintf(buff, "%s%s", begin->lpg, suffix_3p);
+ else if ((diff >= 2) && *suffix_mp)
+ sprintf(buff, "%s%s", begin->lpg, suffix_mp);
+ else
+ sprintf(buff, "%s%s%s", begin->lpg, delim_r, end->lpg);
+
+ encap_range = FALSE;
+ }
+ else
+ sprintf(buff, "%s%s%s", begin->lpg, delim_n, end->lpg);
+ else
+ {
+ encap_range = FALSE; /* might be true from page range on same page */
+ strcpy(buff, begin->lpg);
+ }
+
+ if (*prev_encap != NUL)
+ {
+ strcpy(tmp, buff);
+ sprintf(buff, "%s%s%s%s%s",
+ encap_p, prev_encap, encap_i, tmp, encap_s);
+ }
+ wrap_line(print);
+}
+
+static void
+#if STDC
+wrap_line(int print)
+#else
+wrap_line(print)
+int print;
+#endif
+{
+ int len;
+
+ len = strlen(line) + strlen(buff) + ind_indent;
+ if (print) {
+ if (len > linemax) {
+ PUTLN(line);
+ PUT(indent_space);
+ ind_indent = indent_length;
+ } else
+ PUT(line);
+ PUT(buff);
+ } else {
+ if (len > linemax) {
+ PUTLN(line);
+ sprintf(line, "%s%s%s", indent_space, buff, delim_n);
+ ind_indent = indent_length;
+ } else {
+ strcat(buff, delim_n);
+ strcat(line, buff);
+ }
+ }
+}
+
+
+static void
+insert_page(VOID_ARG)
+{
+ int i = 0;
+ int j = 0;
+ int page = 0;
+
+ if (even_odd >= 0) {
+ /* find the rightmost digit */
+ while (pageno[i++] != NUL);
+ j = --i;
+ /* find the leftmost digit */
+ while (isdigit(pageno[--i]) && i > 0);
+ if (!isdigit(pageno[i]))
+ i++;
+ /* convert page from literal to numeric */
+ page = strtoint(&pageno[i]) + 1;
+ /* check even-odd numbering */
+ if (((even_odd == 1) && (page % 2 == 0)) ||
+ ((even_odd == 2) && (page % 2 == 1)))
+ page++;
+ pageno[j + 1] = NUL;
+ /* convert page back to literal */
+ while (page >= 10) {
+ pageno[j--] = TOASCII(page % 10);
+ page = page / 10;
+ }
+ pageno[j] = TOASCII(page);
+ if (i < j) {
+ while (pageno[j] != NUL)
+ pageno[i++] = pageno[j++];
+ pageno[i] = NUL;
+ }
+ }
+ PUT(setpage_open);
+ PUT(pageno);
+ PUT(setpage_close);
+ ind_lc += setpagelen;
+}
diff --git a/indexing/makeindex/src/genind.h b/indexing/makeindex/src/genind.h
new file mode 100644
index 0000000000..6d0cef06ee
--- /dev/null
+++ b/indexing/makeindex/src/genind.h
@@ -0,0 +1,73 @@
+/*
+ *
+ * This file is part of
+ * MakeIndex - A formatter and format independent index processor
+ *
+ * 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
+ *
+ * Author:
+ * Pehong Chen
+ * Chen & Harrison International Systems, Inc.
+ * Palo Alto, California
+ * USA
+ * (phc@renoir.berkeley.edu or chen@orc.olivetti.com)
+ *
+ * Contributors:
+ * Please refer to the CONTRIB file that comes with this release
+ * for a list of people who have contributed to this and/or previous
+ * release(s) of MakeIndex.
+ *
+ * All rights reserved by the copyright holders. See the copyright
+ * notice distributed with this software for a complete description of
+ * the conditions under which it is made available.
+ *
+ */
+
+#if KCC_20
+/* KCC preprocessor bug collapses multiple blanks to single blank */
+#define IND_ERROR(F, D) { \
+ if (idx_dot) { \
+ fprintf(ilg_fp, "\n"); \
+ idx_dot = FALSE; \
+ } \
+ fprintf(ilg_fp, \
+"## Warning (input = %s, line = %d; output = %s, line = %d):\n\040\040 -- ", \
+ curr->fn, curr->lc, ind_fn, ind_lc+1); \
+ fprintf(ilg_fp, F, D); \
+ ind_ec++; \
+}
+#else
+#define IND_ERROR(F, D) { \
+ if (idx_dot) { \
+ fprintf(ilg_fp, "\n"); \
+ idx_dot = FALSE; \
+ } \
+ fprintf(ilg_fp, \
+ "## Warning (input = %s, line = %d; output = %s, line = %d):\n -- ", \
+ curr->fn, curr->lc, ind_fn, ind_lc+1); \
+ fprintf(ilg_fp, F, D); \
+ ind_ec++; \
+}
+#endif
+
+#define PUTC(C) { \
+ fputc(C, ind_fp); \
+}
+
+#define PUT(S) { \
+ fputs(S, ind_fp); \
+}
+
+#define PUTLN(S) { \
+ fputs(S, ind_fp); \
+ fputc('\n', ind_fp); \
+ ind_lc++; \
+}
+
+#define SAVE { \
+ begin = end = curr; \
+ prev_encap = encap; \
+}
+
diff --git a/indexing/makeindex/src/make-kcc.mic b/indexing/makeindex/src/make-kcc.mic
new file mode 100644
index 0000000000..3a02daeca5
--- /dev/null
+++ b/indexing/makeindex/src/make-kcc.mic
@@ -0,0 +1,13 @@
+! Command file to build MakeIndex on TOPS-20 with KCC
+! [12-Dec-89]
+
+kcc -DOS_TOPS20 -DKCC_20 -DSHORTNAMES -Dshort=int -c genind.c
+kcc -DOS_TOPS20 -DKCC_20 -DSHORTNAMES -Dshort=int -c mkind.c
+kcc -DOS_TOPS20 -DKCC_20 -DSHORTNAMES -Dshort=int -c qsort.c
+kcc -DOS_TOPS20 -DKCC_20 -DSHORTNAMES -Dshort=int -c scanid.c
+kcc -DOS_TOPS20 -DKCC_20 -DSHORTNAMES -Dshort=int -c scanst.c
+kcc -DOS_TOPS20 -DKCC_20 -DSHORTNAMES -Dshort=int -c sortid.c
+kcc -DOS_TOPS20 -DKCC_20 -DSHORTNAMES -Dshort=int genind.rel mkind.rel -
+ qsort.rel scanid.rel scanst.rel sortid.rel -o makidx.exe
+reset
+rename makidx.exe makeindex.exe
diff --git a/indexing/makeindex/src/make-lc.bat b/indexing/makeindex/src/make-lc.bat
new file mode 100644
index 0000000000..23a969b59f
--- /dev/null
+++ b/indexing/makeindex/src/make-lc.bat
@@ -0,0 +1,9 @@
+lc -dOS_PCDOS=1 -dIBM_PC_LATTICE=1 -c -ca -cf -cs -cz -f -ml -S=32K genind.c
+lc -dOS_PCDOS=1 -dIBM_PC_LATTICE=1 -c -ca -cf -cs -cz -f -ml -S=32K mkind.c
+lc -dOS_PCDOS=1 -dIBM_PC_LATTICE=1 -c -ca -cf -cs -cz -f -ml -S=32K qsort.c
+lc -dOS_PCDOS=1 -dIBM_PC_LATTICE=1 -c -ca -cf -cs -cz -f -ml -S=32K scanid.c
+lc -dOS_PCDOS=1 -dIBM_PC_LATTICE=1 -c -ca -cf -cs -cz -f -ml -S=32K scanst.c
+lc -dOS_PCDOS=1 -dIBM_PC_LATTICE=1 -c -ca -cf -cs -cz -f -ml -S=32K sortid.c
+lc -L -f -ml genind.obj mkind.obj qsort.obj scanid.obj scanst.obj sortid.obj
+del makeindx.exe
+ren genind.exe makeindx.exe
diff --git a/indexing/makeindex/src/make-msc.bat b/indexing/makeindex/src/make-msc.bat
new file mode 100644
index 0000000000..5c0dddeecd
--- /dev/null
+++ b/indexing/makeindex/src/make-msc.bat
@@ -0,0 +1,7 @@
+cl -c -AL -Zd -Oailt -W3 -Zi -DOS_PCDOS -DIBM_PC_MICROSOFT genind.c
+cl -c -AL -Zd -Oailt -W3 -Zi -DOS_PCDOS -DIBM_PC_MICROSOFT mkind.c
+cl -c -AL -Zd -Oailt -W3 -Zi -DOS_PCDOS -DIBM_PC_MICROSOFT qsort.c
+cl -c -AL -Zd -Oailt -W3 -Zi -DOS_PCDOS -DIBM_PC_MICROSOFT scanid.c
+cl -c -AL -Zd -Oailt -W3 -Zi -DOS_PCDOS -DIBM_PC_MICROSOFT scanst.c
+cl -c -AL -Zd -Oailt -W3 -Zi -DOS_PCDOS -DIBM_PC_MICROSOFT sortid.c
+cl -o makeindx.exe genind.obj mkind.obj qsort.obj scanid.obj scanst.obj sortid.obj
diff --git a/indexing/makeindex/src/make-pcc.mic b/indexing/makeindex/src/make-pcc.mic
new file mode 100644
index 0000000000..c7226cc3d0
--- /dev/null
+++ b/indexing/makeindex/src/make-pcc.mic
@@ -0,0 +1,13 @@
+! Command file to build MakeIndex on TOPS-20 with PCC
+! [12-Dec-89]
+
+cc -DOS_TOPS20 -DPCC_20 -DSHORTNAMES -c genind.c
+cc -DOS_TOPS20 -DPCC_20 -DSHORTNAMES -c mkind.c
+cc -DOS_TOPS20 -DPCC_20 -DSHORTNAMES -c qsort.c
+cc -DOS_TOPS20 -DPCC_20 -DSHORTNAMES -c scanid.c
+cc -DOS_TOPS20 -DPCC_20 -DSHORTNAMES -c scanst.c
+cc -DOS_TOPS20 -DPCC_20 -DSHORTNAMES -c sortid.c
+cc -DOS_TOPS20 -DPCC_20 -DSHORTNAMES genind.rel mkind.rel qsort.rel -
+ scanid.rel scanst.rel sortid.rel -o makidx.exe
+reset
+rename makidx.exe makeindex.exe
diff --git a/indexing/makeindex/src/make-tcc.bat b/indexing/makeindex/src/make-tcc.bat
new file mode 100644
index 0000000000..a1296828d9
--- /dev/null
+++ b/indexing/makeindex/src/make-tcc.bat
@@ -0,0 +1,7 @@
+tcc -c -A -N -ml -v -y -DOS_PCDOS=1 -DIBM_PC_TURBO=1 genind.c
+tcc -c -A -N -ml -v -y -DOS_PCDOS=1 -DIBM_PC_TURBO=1 mkind.c
+tcc -c -A -N -ml -v -y -DOS_PCDOS=1 -DIBM_PC_TURBO=1 qsort.c
+tcc -c -A -N -ml -v -y -DOS_PCDOS=1 -DIBM_PC_TURBO=1 scanid.c
+tcc -c -A -N -ml -v -y -DOS_PCDOS=1 -DIBM_PC_TURBO=1 scanst.c
+tcc -c -A -N -ml -v -y -DOS_PCDOS=1 -DIBM_PC_TURBO=1 sortid.c
+tcc -A -N -ml -v -y -emakeindx.exe genind.obj mkind.obj qsort.obj scanid.obj scanst.obj sortid.obj
diff --git a/indexing/makeindex/src/make-vms.com b/indexing/makeindex/src/make-vms.com
new file mode 100644
index 0000000000..91abdde610
--- /dev/null
+++ b/indexing/makeindex/src/make-vms.com
@@ -0,0 +1,10 @@
+$! Compile and link MakeIndex under VAX/VMS for people who don't have make.
+$ cc = "CC/NOLIST/DEFINE=(""OS_VAXVMS=1"")"
+$ cc genind
+$ cc mkind
+$ cc qsort
+$ cc scanid
+$ cc scanst
+$ cc sortid
+$ link genind,mkind,qsort,scanid,scanst,sortid,-
+ sys$library:vaxcrtl/lib /exe=makeindex
diff --git a/indexing/makeindex/src/makefile.bsd b/indexing/makeindex/src/makefile.bsd
new file mode 100644
index 0000000000..6f1331bf29
--- /dev/null
+++ b/indexing/makeindex/src/makefile.bsd
@@ -0,0 +1,141 @@
+#
+# Makefile for the program `makeindex'
+#
+# Copyright (C) 1987 Pehong Chen (phc@renoir.berkeley.edu)
+# Computer Science Division
+# University of California, Berkeley
+#
+
+BINDIR = /usr/local/bin
+
+CP = /bin/cp
+
+MANDIR = /usr/local/man/man1
+
+MANUAL = makeindex.l
+
+DOC = makeindex.tex
+
+EXTHDRS = /usr/include/ctype.h \
+ /usr/include/stdio.h
+
+HDRS = genind.h \
+ mkind.h \
+ scanid.h \
+ scanst.h
+
+CFLAGS = -O
+
+LDFLAGS = $(CFLAGS)
+
+LIBS =
+
+LINKER = $(CC)
+
+MAKEFILE = Makefile
+
+OBJS = genind.o \
+ mkind.o \
+ qsort.o \
+ scanid.o \
+ scanst.o \
+ sortid.o
+
+PRINT = psgrind
+
+RM = /bin/rm -f
+
+SRCS = genind.c \
+ mkind.c \
+ qsort.c \
+ scanid.c \
+ scanst.c \
+ sortid.c
+
+PROGRAM = makeindex
+
+TAR = $(PROGRAM).tar
+
+SHAR = $(PROGRAM).shar
+
+ALL = $(MAKEFILE) $(DOC) $(MANUAL) $(HDRS) $(SRCS)
+
+$(PROGRAM): $(OBJS)
+ @ $(RM) -f $(PROGRAM)
+ $(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)
+ @size $(PROGRAM)
+
+install: $(PROGRAM)
+ install -c -s -m 0755 $(PROGRAM) $(BINDIR)
+ install -c -m 0744 ../doc/makeindex.l $(MANDIR)/makeindex.1
+ @ls -lgs $(BINDIR)/$(PROGRAM)
+
+cp-install:
+ $(CP) $(PROGRAM) $(BINDIR)
+ strip $(BINDIR)/$(PROGRAM)
+ chmod 755 $(BINDIR)/$(PROGRAM)
+ $(CP) ../doc/makeindex.l $(MANDIR)/makeindex.1
+ chmod 744 $(MANDIR)/makeindex.1
+
+uninstall:
+ $(RM) $(BINDIR)/$(PROGRAM)
+ $(RM) $(MANDIR)/makeindex.1
+
+tar:
+ @ $(RM) -f $(TAR)
+ tar -cf $(TAR) $(ALL)
+
+shar:
+ @ $(RM) -f $(SHAR)
+ shar $(SHAR) $(ALL)
+
+dist:
+ cp $(PROGRAM) $(BINDIR)
+ rcp $(PROGRAM) monet:$(BINDIR)
+ rcp $(PROGRAM) arpa:$(BINDIR)
+ rcp $(PROGRAM) harrison@vangogh:bin
+
+clean:
+ - $(RM) $(OBJS)
+ - $(RM) core
+ - $(RM) $(PROGRAM)
+ - $(RM) *.out
+
+clobber: clean
+
+depend:
+ @ $(RM) -f .#*.[chly]
+ mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) BINDIR=$(BINDIR)
+
+index:
+ @ctags -wx $(HDRS) $(SRCS)
+
+print:
+ @$(PRINT) $(HDRS) $(SRCS)
+
+man:
+ ptroff -man $(MANUAL)
+
+program: $(PROGRAM)
+
+tags: $(HDRS) $(SRCS)
+ @ctags $(HDRS) $(SRCS)
+
+update: $(BINDIR)/$(PROGRAM)
+
+$(BINDIR)/$(PROGRAM): $(SRCS) $(HDRS) $(EXTHDRS)
+ @make -f $(MAKEFILE) BINDIR=$(BINDIR) install
+
+.DEFAULT:
+ co $@
+###
+genind.o: mkind.h /usr/include/stdio.h /usr/include/ctype.h \
+ genind.h
+mkind.o: mkind.h /usr/include/stdio.h /usr/include/ctype.h
+qsort.o: mkind.h /usr/include/stdio.h
+scanid.o: mkind.h /usr/include/stdio.h /usr/include/ctype.h \
+ scanid.h
+scanst.o: mkind.h /usr/include/stdio.h /usr/include/ctype.h \
+ scanst.h
+sortid.o: mkind.h /usr/include/stdio.h /usr/include/ctype.h
+
diff --git a/indexing/makeindex/src/makefile.kcc b/indexing/makeindex/src/makefile.kcc
new file mode 100644
index 0000000000..034e734a77
--- /dev/null
+++ b/indexing/makeindex/src/makefile.kcc
@@ -0,0 +1,123 @@
+# Makefile modified for DEC-20 (KCC-20 compiler) [13-Jan-88] (only major
+# targets supported)
+#
+# Makefile for the program `makeindex'
+#
+# Copyright (C) 1987 Pehong Chen (phc@renoir.berkeley.edu)
+# Computer Science Division
+# University of California, Berkeley
+#
+
+CC = kcc
+O = .rel
+X = .exe
+INCLUDE = /usr/include/
+INCLUDE = c:
+
+DEST = /usr/local/bin
+DEST = TEX:
+
+MANDIR = /usr/local/man/manl
+MANDIR = NUL:
+
+MANUAL = makeindex.l
+
+DOC = makeindex.tex
+
+EXTHDRS = ${INCLUDE}ctype.h \
+ ${INCLUDE}stdio.h
+
+HDRS = genind.h \
+ mkind.h \
+ scanid.h \
+ scanst.h
+
+# The -Dshort=int is needed for KCC versions before 583 (13-Jan-88);
+# that version or later works correctly if it is dropped
+CFLAGS = -DOS_TOPS20 -DKCC_20 -DSHORTNAMES -Dshort=int
+
+LDFLAGS = $(CFLAGS)
+
+LIBS =
+
+LINKER = $(CC)
+
+MAKEFILE = Makefile
+
+OBJS = genind${O} \
+ mkind${O} \
+ qsort${O} \
+ scanid${O} \
+ scanst${O} \
+ sortid${O}
+
+PRINT = psgrind
+
+SRCS = genind.c \
+ mkind.c \
+ qsort.c \
+ scanid.c \
+ scanst.c \
+ sortid.c
+
+PROGRAM = makeindex
+
+TAR = $(PROGRAM).tar
+
+SHAR = $(PROGRAM).shar
+
+ALL = $(MAKEFILE) $(DOC) $(MANUAL) $(HDRS) $(SRCS)
+
+$(PROGRAM): $(PROGRAM)$(X)
+
+$(PROGRAM)$(X): $(OBJS)
+ $(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o makidx$(X)
+ reset
+ ${MV} makidx$(X) $(PROGRAM)$(X)
+
+install: $(PROGRAM)
+ install -c -s -m 0755 $(PROGRAM) $(DEST)
+ @ls -lgs $(DEST)/$(PROGRAM)
+
+tar:; @rm -f $(TAR)
+ tar -cf $(TAR) $(ALL)
+
+shar:; @rm -f $(SHAR)
+ shar $(SHAR) $(ALL)
+
+dist:; cp $(PROGRAM) $(DEST)
+ rcp $(PROGRAM) monet:$(DEST)
+ rcp $(PROGRAM) arpa:$(DEST)
+ rcp $(PROGRAM) harrison@vangogh:bin
+
+clean:; @rm -f $(OBJS) core $(PROGRAM) *${O}ut
+
+depend:; @rm -f .#*.[chly]
+ mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
+
+index:; @ctags -wx $(HDRS) $(SRCS)
+
+print:; @$(PRINT) $(HDRS) $(SRCS)
+
+man:; ptroff -man $(MANUAL)
+
+program: $(PROGRAM)
+
+tags: $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
+
+update: $(DEST)/$(PROGRAM)
+
+$(DEST)/$(PROGRAM): $(SRCS) $(HDRS) $(EXTHDRS)
+ @make -f $(MAKEFILE) DEST=$(DEST) install
+
+# .DEFAULT:; co $@
+###
+genind${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h \
+ genind.h
+mkind${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h
+qsort${O}: mkind.h ${INCLUDE}stdio.h
+scanid${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h \
+ scanid.h
+scanst${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h \
+ scanst.h
+sortid${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h
diff --git a/indexing/makeindex/src/makefile.lc b/indexing/makeindex/src/makefile.lc
new file mode 100644
index 0000000000..f1d5725bef
--- /dev/null
+++ b/indexing/makeindex/src/makefile.lc
@@ -0,0 +1,139 @@
+# Makefile modified for IBM PC DOS (Lattice C 6.0.1) [11-Dec-89] (only major
+# targets supported)
+#
+# Makefile for the program `makeindex'
+#
+# Copyright (C) 1987 Pehong Chen (phc@renoir.berkeley.edu)
+# Computer Science Division
+# University of California, Berkeley
+#
+
+CC = lc
+O = .obj
+X = .exe
+INCLUDE = /usr/include
+INCLUDE = c:/sys/lc/include
+
+DEST = /usr/local/bin
+DEST = c:/usr/bin
+
+MANDIR = /usr/local/man/manl
+MANDIR = nul
+
+MANUAL = makeindex.l
+
+DOC = makeindex.tex
+
+EXTHDRS = ${INCLUDE}\ctype.h \
+ ${INCLUDE}\stdio.h
+
+HDRS = genind.h \
+ mkind.h \
+ scanid.h \
+ scanst.h
+
+XCFLAGS=
+
+LDFLAGS = -L -f -ml $(XCFLAGS)
+
+CFLAGS = -dOS_PCDOS=1 -dIBM_PC_LATTICE=1 -c -ca -cf -cs -cz -f -ml -S=32K
+
+LIBS =
+
+LINKER = link
+
+MAKEFILE = Makefile
+
+OBJS = genind${O} mkind${O} qsort${O} scanid${O} scanst${O} sortid${O}
+
+PRINT = psgrind
+
+SRCS = genind.c \
+ mkind.c \
+ qsort.c \
+ scanid.c \
+ scanst.c \
+ sortid.c
+
+PROGRAM = makeindx
+
+TAR = $(PROGRAM).tar
+
+SHAR = $(PROGRAM).shar
+
+ALL = $(MAKEFILE) $(DOC) $(MANUAL) $(HDRS) $(SRCS)
+
+# Default stack is too small--increase
+STACKSIZE=8000
+
+LINKFLAGS=/MAP/LINE/ST:$(STACKSIZE)
+
+# Rules...
+
+.SUFFIXES:
+.SUFFIXES: .obj .c
+
+.c.obj:
+ $(CC) $(CFLAGS) $*.c
+
+RM = del
+
+$(PROGRAM): $(PROGRAM)$(X)
+
+$(PROGRAM)$(X): $(OBJS)
+ $(CC) $(LDFLAGS) $(OBJS)
+ del $(PROGRAM)$(X)
+ ren genind$(X) $(PROGRAM)$(X)
+
+install: $(PROGRAM)
+ install -c -s -m 0755 $(PROGRAM) $(DEST)
+ @ls -lgs $(DEST)/$(PROGRAM)
+
+tar:
+ @rm -f $(TAR)
+ tar -cf $(TAR) $(ALL)
+
+shar:
+ @rm -f $(SHAR)
+ shar $(SHAR) $(ALL)
+
+dist:
+ cp $(PROGRAM) $(DEST)
+ rcp $(PROGRAM) monet:$(DEST)
+ rcp $(PROGRAM) arpa:$(DEST)
+ rcp $(PROGRAM) harrison@vangogh:bin
+
+clean:
+ @rm -f $(OBJS) core $(PROGRAM) *${O}ut
+
+depend:
+ @rm -f .#*.[chly]
+ mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
+
+index:
+ @ctags -wx $(HDRS) $(SRCS)
+
+print:
+ @$(PRINT) $(HDRS) $(SRCS)
+
+man:
+ ptroff -man $(MANUAL)
+
+program: $(PROGRAM)
+
+tags: $(HDRS) $(SRCS)
+ @ctags $(HDRS) $(SRCS)
+
+# update: $(DEST)/$(PROGRAM)
+
+# $(DEST)/$(PROGRAM): $(SRCS) $(HDRS) $(EXTHDRS)
+# @make -f $(MAKEFILE) DEST=$(DEST) install
+
+# .DEFAULT:; co $@
+###
+genind${O}: mkind.h genind.h
+mkind${O}: mkind.h
+qsort${O}: mkind.h
+scanid${O}: mkind.h scanid.h
+scanst${O}: mkind.h scanst.h
+sortid${O}: mkind.h
diff --git a/indexing/makeindex/src/makefile.msc b/indexing/makeindex/src/makefile.msc
new file mode 100644
index 0000000000..8e37e8f79a
--- /dev/null
+++ b/indexing/makeindex/src/makefile.msc
@@ -0,0 +1,144 @@
+# Makefile modified for IBM PC DOS (Microsoft C) [13-Jan-88] (only major
+# targets supported)
+#
+# Makefile for the program `makeindex'
+#
+# Copyright (C) 1987 Pehong Chen (phc@renoir.berkeley.edu)
+# Computer Science Division
+# University of California, Berkeley
+#
+
+CC = cl
+O = .obj
+X = .exe
+INCLUDE = /usr/include
+INCLUDE = c:/sys/msc/include
+
+DEST = /usr/local/bin
+DEST = c:/usr/bin
+
+MANDIR = /usr/local/man/manl
+MANDIR = nul
+
+MANUAL = makeindex.l
+
+DOC = makeindex.tex
+
+EXTHDRS = ${INCLUDE}\ctype.h \
+ ${INCLUDE}\stdio.h
+
+HDRS = genind.h \
+ mkind.h \
+ scanid.h \
+ scanst.h
+
+XCFLAGS=
+
+CFLAGS= -AL -Zd -Oailt -W3 -Zi -DOS_PCDOS -DIBM_PC_MICROSOFT $(XCFLAGS)
+
+LDFLAGS = $(CFLAGS)
+
+LIBS =
+
+LINKER = link
+
+MAKEFILE = Makefile
+
+OBJS = genind${O} mkind${O} qsort${O} scanid${O} scanst${O} sortid${O}
+
+PRINT = psgrind
+
+SRCS = genind.c \
+ mkind.c \
+ qsort.c \
+ scanid.c \
+ scanst.c \
+ sortid.c
+
+PROGRAM = makeindx
+
+TAR = $(PROGRAM).tar
+
+SHAR = $(PROGRAM).shar
+
+ALL = $(MAKEFILE) $(DOC) $(MANUAL) $(HDRS) $(SRCS)
+
+# Default stack is too small--increase
+STACKSIZE=8000
+
+LINKFLAGS=/MAP/LINE/ST:$(STACKSIZE)
+
+# Rules...
+
+.SUFFIXES:
+.SUFFIXES: .obj .c .sym .map
+
+.c.obj:
+ $(CC) -c $(CFLAGS) $*.c
+# $(CC) -c $(CFLAGS) $*.c >$*.clg
+# errshow <$*.clg >$*.cer
+# del $*.clg
+
+.map.sym:
+ mapsym $*
+ del $*.map
+
+RM = del
+
+$(PROGRAM): $(PROGRAM)$(X)
+
+$(PROGRAM)$(X): $(OBJS)
+ $(CC) -o $(PROGRAM)$(X) $(OBJS)
+
+install: $(PROGRAM)
+ install -c -s -m 0755 $(PROGRAM) $(DEST)
+ @ls -lgs $(DEST)/$(PROGRAM)
+
+tar:
+ @rm -f $(TAR)
+ tar -cf $(TAR) $(ALL)
+
+shar:
+ @rm -f $(SHAR)
+ shar $(SHAR) $(ALL)
+
+dist:
+ cp $(PROGRAM) $(DEST)
+ rcp $(PROGRAM) monet:$(DEST)
+ rcp $(PROGRAM) arpa:$(DEST)
+ rcp $(PROGRAM) harrison@vangogh:bin
+
+clean:
+ @rm -f $(OBJS) $(PROGRAM)$(X)
+
+depend:
+ @rm -f .#*.[chly]
+ mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
+
+index:
+ @ctags -wx $(HDRS) $(SRCS)
+
+print:
+ @$(PRINT) $(HDRS) $(SRCS)
+
+man:
+ ptroff -man $(MANUAL)
+
+program: $(PROGRAM)
+
+tags: $(HDRS) $(SRCS)
+ @ctags $(HDRS) $(SRCS)
+
+# update: $(DEST)/$(PROGRAM)
+
+# $(DEST)/$(PROGRAM): $(SRCS) $(HDRS) $(EXTHDRS)
+# @make -f $(MAKEFILE) DEST=$(DEST) install
+
+# .DEFAULT:; co $@
+###
+genind${O}: mkind.h genind.h
+mkind${O}: mkind.h
+qsort${O}: mkind.h
+scanid${O}: mkind.h scanid.h
+scanst${O}: mkind.h scanst.h
+sortid${O}: mkind.h
diff --git a/indexing/makeindex/src/makefile.os2 b/indexing/makeindex/src/makefile.os2
new file mode 100644
index 0000000000..ac4b7efd03
--- /dev/null
+++ b/indexing/makeindex/src/makefile.os2
@@ -0,0 +1,138 @@
+# Makefile modified for IBM PC DOS (Microsoft C) [13-Jan-88] (only major
+# targets supported)
+#
+# Modified by Eberhard Mattes for OS/2 and MS C 6.0 [18-Jul-90]
+#
+# Makefile for the program `makeindex'
+#
+# Copyright (C) 1987 Pehong Chen (phc@renoir.berkeley.edu)
+# Computer Science Division
+# University of California, Berkeley
+#
+
+CC = cl
+O = .obj
+X = .exe
+# INCLUDE = /usr/include
+# INCLUDE = c:/sys/msc/include
+
+DEST = /usr/local/bin
+DEST = c:/usr/bin
+
+MANDIR = /usr/local/man/manl
+MANDIR = nul
+
+MANUAL = makeindex.l
+
+DOC = makeindex.tex
+
+HDRS = genind.h \
+ mkind.h \
+ scanid.h \
+ scanst.h
+
+XCFLAGS=
+
+CFLAGS= -AL -Ocegls -W3 -F 2000 -Lp -Fb -B2 C2L -DOS_PCDOS -DIBM_PC_MICROSOFT $(XCFLAGS)
+#
+# -AL Large model
+# -Oc Block-level common subexpression optimization
+# -Oe Global register allocation
+# -Og Global code optimization
+# -Ol Loop code optimization
+# -Os Optimize for space (I prefer small and slow programs)
+# -Oi Generate intrinsic functions (not used, see line above)
+# -W3 Set warning level (level 4 not required)
+# -F 2000 Set stack size (hexadecimal!)
+# -Lp Link for protected mode (use llibceP.lib)
+# -Fb Invoke bind
+# -B2 C2L Large-model pass 2 (OS/2 only, required for -Og)
+
+
+LDFLAGS = $(CFLAGS)
+
+LIBS =
+
+LINKER = link
+
+MAKEFILE = Makefile
+
+OBJS = genind$(O) mkind$(O) qsort$(O) scanid$(O) scanst$(O) sortid$(O)
+
+PRINT = psgrind
+
+SRCS = genind.c \
+ mkind.c \
+ qsort.c \
+ scanid.c \
+ scanst.c \
+ sortid.c
+
+PROGRAM = makeindx
+
+TAR = $(PROGRAM).tar
+
+SHAR = $(PROGRAM).shar
+
+ALL = $(MAKEFILE) $(DOC) $(MANUAL) $(HDRS) $(SRCS)
+
+# Rules...
+
+.SUFFIXES:
+.SUFFIXES: .obj .c
+
+.c.obj:
+ $(CC) -c $(CFLAGS) $*.c
+
+RM = del
+
+$(PROGRAM): $(PROGRAM)$(X)
+
+$(PROGRAM)$(X): $(OBJS) $(PROGRAM).def
+ $(CC) -o $(PROGRAM)$(X) $(CFLAGS) $(OBJS) $(PROGRAM).def
+
+install: $(PROGRAM)
+ install -c -s -m 0755 $(PROGRAM) $(DEST)
+ @ls -lgs $(DEST)/$(PROGRAM)
+
+tar:
+ @rm -f $(TAR)
+ tar -cf $(TAR) $(ALL)
+
+shar:
+ @rm -f $(SHAR)
+ shar $(SHAR) $(ALL)
+
+dist:
+ cp $(PROGRAM) $(DEST)
+ rcp $(PROGRAM) monet:$(DEST)
+ rcp $(PROGRAM) arpa:$(DEST)
+ rcp $(PROGRAM) harrison@vangogh:bin
+
+clean:
+ @rm -f $(OBJS) core $(PROGRAM) *$(O)
+
+depend:
+ @rm -f .#*.[chly]
+ mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
+
+index:
+ @ctags -wx $(HDRS) $(SRCS)
+
+print:
+ @$(PRINT) $(HDRS) $(SRCS)
+
+man:
+ ptroff -man $(MANUAL)
+
+program: $(PROGRAM)
+
+tags: $(HDRS) $(SRCS)
+ @ctags $(HDRS) $(SRCS)
+
+genind$(O): mkind.h genind.h
+mkind$(O): mkind.h
+qsort$(O): mkind.h
+scanid$(O): mkind.h scanid.h
+scanst$(O): mkind.h scanst.h
+sortid$(O): mkind.h
diff --git a/indexing/makeindex/src/makefile.pcc b/indexing/makeindex/src/makefile.pcc
new file mode 100644
index 0000000000..1471626de1
--- /dev/null
+++ b/indexing/makeindex/src/makefile.pcc
@@ -0,0 +1,124 @@
+# Makefile modified for DEC-20 (PCC-20 compiler) [13-Jan-88] (only major
+# targets supported)
+#
+# Makefile for the program `makeindex'
+#
+# Copyright (C) 1987 Pehong Chen (phc@renoir.berkeley.edu)
+# Computer Science Division
+# University of California, Berkeley
+#
+
+CC = cc
+O = .rel
+X = .exe
+INCLUDE = /usr/include/
+INCLUDE = pcc:
+
+DEST = /usr/local/bin
+DEST = TEX:
+
+MANDIR = /usr/local/man/manl
+MANDIR = NUL:
+
+MANUAL = makeindex.l
+
+DOC = makeindex.tex
+
+EXTHDRS = ${INCLUDE}ctype.h \
+ ${INCLUDE}stdio.h
+
+HDRS = genind.h \
+ mkind.h \
+ scanid.h \
+ scanst.h
+
+CFLAGS = -DOS_TOPS20 -DPCC_20 -DSHORTNAMES
+
+LDFLAGS = $(CFLAGS)
+
+LIBS =
+
+LINKER = $(CC)
+
+MAKEFILE = Makefile
+
+OBJS = genind${O} \
+ mkind${O} \
+ qsort${O} \
+ scanid${O} \
+ scanst${O} \
+ sortid${O}
+
+PRINT = psgrind
+
+SRCS = genind.c \
+ mkind.c \
+ qsort.c \
+ scanid.c \
+ scanst.c \
+ sortid.c
+
+PROGRAM = makeindex
+
+TAR = $(PROGRAM).tar
+
+SHAR = $(PROGRAM).shar
+
+ALL = $(MAKEFILE) $(DOC) $(MANUAL) $(HDRS) $(SRCS)
+
+$(PROGRAM): $(PROGRAM)$(X)
+
+$(PROGRAM)$(X): $(OBJS)
+# @rm -f $(PROGRAM)
+ $(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o makidx$(X)
+ reset
+ ${MV} makidx$(X) $(PROGRAM)$(X)
+# @size $(PROGRAM)
+
+install: $(PROGRAM)
+ install -c -s -m 0755 $(PROGRAM) $(DEST)
+ @ls -lgs $(DEST)/$(PROGRAM)
+
+tar:; @rm -f $(TAR)
+ tar -cf $(TAR) $(ALL)
+
+shar:; @rm -f $(SHAR)
+ shar $(SHAR) $(ALL)
+
+dist:; cp $(PROGRAM) $(DEST)
+ rcp $(PROGRAM) monet:$(DEST)
+ rcp $(PROGRAM) arpa:$(DEST)
+ rcp $(PROGRAM) harrison@vangogh:bin
+
+clean:; @rm -f $(OBJS) core $(PROGRAM) *${O}ut
+
+depend:; @rm -f .#*.[chly]
+ mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
+
+index:; @ctags -wx $(HDRS) $(SRCS)
+
+print:; @$(PRINT) $(HDRS) $(SRCS)
+
+man:; ptroff -man $(MANUAL)
+
+program: $(PROGRAM)
+
+tags: $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
+
+update: $(DEST)/$(PROGRAM)
+
+$(DEST)/$(PROGRAM): $(SRCS) $(HDRS) $(EXTHDRS)
+ @make -f $(MAKEFILE) DEST=$(DEST) install
+
+# .DEFAULT:; co $@
+###
+genind${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h \
+ genind.h
+mkind${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h
+qsort${O}: mkind.h ${INCLUDE}stdio.h
+scanid${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h \
+ scanid.h
+scanst${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h \
+ scanst.h
+sortid${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h
+
diff --git a/indexing/makeindex/src/makefile.tcc b/indexing/makeindex/src/makefile.tcc
new file mode 100644
index 0000000000..7ad0c12c91
--- /dev/null
+++ b/indexing/makeindex/src/makefile.tcc
@@ -0,0 +1,146 @@
+# Makefile modified for IBM PC DOS (Turbo C 2.0) [11-Dec-89] (only major
+# targets supported)
+#
+# Makefile for the program `makeindex'
+#
+# Copyright (C) 1987 Pehong Chen (phc@renoir.berkeley.edu)
+# Computer Science Division
+# University of California, Berkeley
+#
+
+CC = tcc
+O = .obj
+X = .exe
+INCLUDE = /usr/include
+INCLUDE = c:/sys/tc/include
+
+DEST = /usr/local/bin
+DEST = c:/usr/bin
+
+MANDIR = /usr/local/man/manl
+MANDIR = nul
+
+MANUAL = makeindex.l
+
+DOC = makeindex.tex
+
+EXTHDRS = ${INCLUDE}\ctype.h \
+ ${INCLUDE}\stdio.h
+
+HDRS = genind.h \
+ mkind.h \
+ scanid.h \
+ scanst.h
+
+XCFLAGS=
+
+LDFLAGS = -A -N -ml -v -y $(XCFLAGS)
+
+CFLAGS = -DOS_PCDOS=1 -DIBM_PC_TURBO=1 $(LDFLAGS)
+
+LIBS =
+
+LINKER = link
+
+MAKEFILE = Makefile
+
+OBJS = genind${O} mkind${O} qsort${O} scanid${O} scanst${O} sortid${O}
+
+PRINT = psgrind
+
+SRCS = genind.c \
+ mkind.c \
+ qsort.c \
+ scanid.c \
+ scanst.c \
+ sortid.c
+
+PROGRAM = makeindx
+
+TAR = $(PROGRAM).tar
+
+SHAR = $(PROGRAM).shar
+
+ALL = $(MAKEFILE) $(DOC) $(MANUAL) $(HDRS) $(SRCS)
+
+# Default stack is too small--increase
+STACKSIZE=8000
+
+LINKFLAGS=/MAP/LINE/ST:$(STACKSIZE)
+
+# Rules...
+
+.SUFFIXES:
+.SUFFIXES: .obj .c .sym .map
+
+.c.obj:
+ $(CC) -c $(CFLAGS) $*.c
+# $(CC) -c $(CFLAGS) $*.c >$*.clg
+# errshow <$*.clg >$*.cer
+# del $*.clg
+
+.map.sym:
+ mapsym $*
+ del $*.map
+
+RM = del
+
+$(PROGRAM): $(PROGRAM)$(X)
+
+$(PROGRAM)$(X): $(OBJS)
+# @rm -f $(PROGRAM)
+ $(CC) $(LDFLAGS) -e$(PROGRAM)$(X) $(OBJS)
+# @size $(PROGRAM)
+
+install: $(PROGRAM)
+ install -c -s -m 0755 $(PROGRAM) $(DEST)
+ @ls -lgs $(DEST)/$(PROGRAM)
+
+tar:
+ @rm -f $(TAR)
+ tar -cf $(TAR) $(ALL)
+
+shar:
+ @rm -f $(SHAR)
+ shar $(SHAR) $(ALL)
+
+dist:
+ cp $(PROGRAM) $(DEST)
+ rcp $(PROGRAM) monet:$(DEST)
+ rcp $(PROGRAM) arpa:$(DEST)
+ rcp $(PROGRAM) harrison@vangogh:bin
+
+clean:
+ @rm -f $(OBJS) core $(PROGRAM) *${O}ut
+
+depend:
+ @rm -f .#*.[chly]
+ mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
+
+index:
+ @ctags -wx $(HDRS) $(SRCS)
+
+print:
+ @$(PRINT) $(HDRS) $(SRCS)
+
+man:
+ ptroff -man $(MANUAL)
+
+program: $(PROGRAM)
+
+tags: $(HDRS) $(SRCS)
+ @ctags $(HDRS) $(SRCS)
+
+# update: $(DEST)/$(PROGRAM)
+
+# $(DEST)/$(PROGRAM): $(SRCS) $(HDRS) $(EXTHDRS)
+# @make -f $(MAKEFILE) DEST=$(DEST) install
+
+# .DEFAULT:; co $@
+###
+genind${O}: mkind.h genind.h
+mkind${O}: mkind.h
+qsort${O}: mkind.h
+scanid${O}: mkind.h scanid.h
+scanst${O}: mkind.h scanst.h
+sortid${O}: mkind.h
diff --git a/indexing/makeindex/src/makefile.usg b/indexing/makeindex/src/makefile.usg
new file mode 100644
index 0000000000..634c53d243
--- /dev/null
+++ b/indexing/makeindex/src/makefile.usg
@@ -0,0 +1,134 @@
+
+#
+# Makefile for the program `makeindex'
+#
+# Copyright (C) 1987 Pehong Chen (phc@renoir.berkeley.edu)
+# Computer Science Division
+# University of California, Berkeley
+#
+
+BINDIR = /usr/local/bin
+
+MANDIR = /usr/local/man/manl
+
+MANUAL = makeindex.l
+
+DOC = makeindex.tex
+
+EXTHDRS = /usr/include/ctype.h \
+ /usr/include/stdio.h
+
+HDRS = genind.h \
+ mkind.h \
+ scanid.h \
+ scanst.h
+
+CFLAGS = -O -DOS_SYSV
+
+LDFLAGS = $(CFLAGS)
+
+LIBS =
+
+LINKER = $(CC)
+
+MAKEFILE = Makefile
+
+OBJS = genind.o \
+ mkind.o \
+ qsort.o \
+ scanid.o \
+ scanst.o \
+ sortid.o
+
+PRINT = psgrind
+
+SRCS = genind.c \
+ mkind.c \
+ qsort.c \
+ scanid.c \
+ scanst.c \
+ sortid.c
+
+PROGRAM = makeindex
+
+TAR = $(PROGRAM).tar
+
+SHAR = $(PROGRAM).shar
+
+ALL = $(MAKEFILE) $(DOC) $(MANUAL) $(HDRS) $(SRCS)
+
+$(PROGRAM): $(OBJS)
+ @rm -f $(PROGRAM)
+ $(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)
+ @size $(PROGRAM)
+
+install: $(PROGRAM)
+ install -c -s -m 0755 $(PROGRAM) $(BINDIR)
+ install -c -m 0744 ../doc/makeindex.l $(MANDIR)/makeindex.1
+ @ls -lgs $(BINDIR)/$(PROGRAM)
+
+cp-install:
+ $(CP) $(PROGRAM) $(BINDIR)
+ strip $(BINDIR)/$(PROGRAM)
+ chmod 755 $(BINDIR)/$(PROGRAM)
+ $(CP) ../doc/makeindex.l $(MANDIR)/makeindex.1
+ chmod 744 $(MANDIR)/makeindex.1
+
+uninstall:
+ $(RM) $(BINDIR)/$(PROGRAM)
+ $(RM) $(MANDIR)/makeindex.1
+
+
+tar:
+ @rm -f $(TAR)
+ tar -cf $(TAR) $(ALL)
+
+shar:
+ @rm -f $(SHAR)
+ shar $(SHAR) $(ALL)
+
+dist:
+ cp $(PROGRAM) $(BINDIR)
+ rcp $(PROGRAM) monet:$(BINDIR)
+ rcp $(PROGRAM) arpa:$(BINDIR)
+ rcp $(PROGRAM) harrison@vangogh:bin
+
+clean:
+ @rm -f $(OBJS) core $(PROGRAM) *.out
+
+depend:
+ @rm -f .#*.[chly]
+ mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) BINDIR=$(BINDIR)
+
+index:
+ @ctags -wx $(HDRS) $(SRCS)
+
+print:
+ @$(PRINT) $(HDRS) $(SRCS)
+
+man:
+ ptroff -man $(MANUAL)
+
+program: $(PROGRAM)
+
+tags: $(HDRS) $(SRCS)
+ @ctags $(HDRS) $(SRCS)
+
+update: $(BINDIR)/$(PROGRAM)
+
+$(BINDIR)/$(PROGRAM): $(SRCS) $(HDRS) $(EXTHDRS)
+ @make -f $(MAKEFILE) BINDIR=$(BINDIR) install
+
+.DEFAULT:
+ co $@
+###
+genind.o: mkind.h /usr/include/stdio.h /usr/include/ctype.h \
+ genind.h
+mkind.o: mkind.h /usr/include/stdio.h /usr/include/ctype.h
+qsort.o: mkind.h /usr/include/stdio.h
+scanid.o: mkind.h /usr/include/stdio.h /usr/include/ctype.h \
+ scanid.h
+scanst.o: mkind.h /usr/include/stdio.h /usr/include/ctype.h \
+ scanst.h
+sortid.o: mkind.h /usr/include/stdio.h /usr/include/ctype.h
+
diff --git a/indexing/makeindex/src/makefile.vms b/indexing/makeindex/src/makefile.vms
new file mode 100644
index 0000000000..46159bee6a
--- /dev/null
+++ b/indexing/makeindex/src/makefile.vms
@@ -0,0 +1,124 @@
+# Makefile modified for DEC VAX VMS [13-Jan-88] (only major
+# targets supported)
+#
+# Makefile for the program `makeindex'
+#
+# Copyright (C) 1987 Pehong Chen (phc@renoir.berkeley.edu)
+# Computer Science Division
+# University of California, Berkeley
+#
+
+CC = cc
+O = .obj
+X = .exe
+INCLUDE = /usr/include/
+INCLUDE = sys$$library:
+
+DEST = /usr/local/bin
+DEST = TEX:
+
+MANDIR = /usr/local/man/manl
+MANDIR = NUL:
+
+MANUAL = makeindex.l
+
+DOC = makeindex.tex
+
+EXTHDRS = ${INCLUDE}ctype.h \
+ ${INCLUDE}stdio.h
+
+HDRS = genind.h \
+ mkind.h \
+ scanid.h \
+ scanst.h
+
+CFLAGS = /DEFINE=("OS_VAXVMS=1")
+
+LDFLAGS =
+
+LIBS = sys$$library:vaxcrtl/lib
+#LIBS = plt:unixclib/lib,sys$$library:vaxcrtl/lib
+
+LINKER = link
+
+MAKEFILE = Makefile
+
+OBJS = genind${O} \
+ mkind${O} \
+ qsort${O} \
+ scanid${O} \
+ scanst${O} \
+ sortid${O}
+
+OBJLIST = genind${O},mkind${O},qsort${O},scanid${O},scanst${O},sortid${O}
+
+PRINT = psgrind
+
+SRCS = genind.c \
+ mkind.c \
+ qsort.c \
+ scanid.c \
+ scanst.c \
+ sortid.c
+
+PROGRAM = makeindex
+
+TAR = $(PROGRAM).tar
+
+SHAR = $(PROGRAM).shar
+
+ALL = $(MAKEFILE) $(DOC) $(MANUAL) $(HDRS) $(SRCS)
+
+$(PROGRAM): $(PROGRAM)$(X)
+
+$(PROGRAM)$(X): $(OBJS)
+# @rm -f $(PROGRAM)
+ $(LINKER) /exec=$(PROGRAM) $(LDFLAGS) $(OBJLIST),$(LIBS)
+# @size $(PROGRAM)
+
+install: $(PROGRAM)
+ install -c -s -m 0755 $(PROGRAM) $(DEST)
+ @ls -lgs $(DEST)/$(PROGRAM)
+
+tar:; @rm -f $(TAR)
+ tar -cf $(TAR) $(ALL)
+
+shar:; @rm -f $(SHAR)
+ shar $(SHAR) $(ALL)
+
+dist:; cp $(PROGRAM) $(DEST)
+ rcp $(PROGRAM) monet:$(DEST)
+ rcp $(PROGRAM) arpa:$(DEST)
+ rcp $(PROGRAM) harrison@vangogh:bin
+
+clean:; @rm -f $(OBJS) core $(PROGRAM) *${O}ut
+
+depend:; @rm -f .#*.[chly]
+ mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
+
+index:; @ctags -wx $(HDRS) $(SRCS)
+
+print:; @$(PRINT) $(HDRS) $(SRCS)
+
+man:; ptroff -man $(MANUAL)
+
+program: $(PROGRAM)
+
+tags: $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
+
+update: $(DEST)/$(PROGRAM)
+
+$(DEST)/$(PROGRAM): $(SRCS) $(HDRS) $(EXTHDRS)
+ @make -f $(MAKEFILE) DEST=$(DEST) install
+
+.DEFAULT:; co $@
+###
+genind${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h \
+ genind.h
+mkind${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h
+qsort${O}: mkind.h ${INCLUDE}stdio.h
+scanid${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h \
+ scanid.h
+scanst${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h \
+ scanst.h
+sortid${O}: mkind.h ${INCLUDE}stdio.h ${INCLUDE}ctype.h
diff --git a/indexing/makeindex/src/makeindx.def b/indexing/makeindex/src/makeindx.def
new file mode 100644
index 0000000000..6d31171722
--- /dev/null
+++ b/indexing/makeindex/src/makeindx.def
@@ -0,0 +1,2 @@
+NAME Makeindx WINDOWCOMPAT
+DESCRIPTION 'MakeIndex - General purpose index processor'
diff --git a/indexing/makeindex/src/mkind.c b/indexing/makeindex/src/mkind.c
new file mode 100644
index 0000000000..4df0015d1e
--- /dev/null
+++ b/indexing/makeindex/src/mkind.c
@@ -0,0 +1,720 @@
+/*
+ *
+ * This file is part of
+ * MakeIndex - A formatter and format independent index processor
+ *
+ * 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
+ *
+ * Author:
+ * Pehong Chen
+ * Chen & Harrison International Systems, Inc.
+ * Palo Alto, California
+ * USA
+ * (phc@renoir.berkeley.edu or chen@orc.olivetti.com)
+ *
+ * Contributors:
+ * Please refer to the CONTRIB file that comes with this release
+ * for a list of people who have contributed to this and/or previous
+ * release(s) of MakeIndex.
+ *
+ * All rights reserved by the copyright holders. See the copyright
+ * notice distributed with this software for a complete description of
+ * the conditions under which it is made available.
+ *
+ */
+
+#define MKIND_C 1
+#include "mkind.h"
+#undef MKIND_C
+
+int letter_ordering = FALSE;
+int compress_blanks = FALSE;
+int merge_page = TRUE;
+int init_page = FALSE;
+int even_odd = -1;
+int verbose = TRUE;
+int german_sort = FALSE;
+int fn_no = -1; /* total number of files */
+int idx_dot = TRUE; /* flag which shows dot in ilg being
+ * active */
+int idx_tt = 0; /* total entry count (all files) */
+int idx_et = 0; /* erroneous entry count (all files) */
+int idx_gt = 0; /* good entry count (all files) */
+
+FIELD_PTR *idx_key;
+FILE *log_fp;
+FILE *sty_fp;
+FILE *idx_fp;
+FILE *ind_fp;
+FILE *ilg_fp;
+
+#if OS_BS2000
+FILE *widx_fp;
+char widx_fn[STRING_MAX + 5];
+#endif /* OS_BS2000 */
+
+char *pgm_fn;
+char sty_fn[LINE_MAX];
+char *idx_fn;
+char ind[STRING_MAX];
+char *ind_fn;
+char ilg[STRING_MAX];
+char *ilg_fn;
+char pageno[NUMBER_MAX];
+
+static char log_fn[STRING_MAX];
+static char base[STRING_MAX];
+static int need_version = TRUE;
+
+static void check_all ARGS((char *fn,int ind_given,int ilg_given,
+ int log_given));
+static void check_idx ARGS((char *fn,int open_fn));
+static void find_pageno ARGS((void));
+static void open_sty ARGS((char *fn));
+static void prepare_idx ARGS((void));
+static void process_idx ARGS((char * *fn,int use_stdin,int sty_given,
+ int ind_given,int ilg_given,int log_given));
+
+#if OS_PCDOS
+#if IBM_PC_TURBO
+unsigned _stklen = 0xf000; /* Turbo C ignores size set in
+ .exe file by LINK or EXEMOD,
+ sigh... */
+#endif /* IBM_PC_TURBO */
+#endif /* OS_PCDOS */
+
+#if OS_ATARI
+long _stksize = 20000L; /* make the stack larger than 2KB */
+/* size must be given */
+#endif /* OS_ATARI */
+
+#ifdef DEBUG
+long totmem = 0L; /* for debugging memory usage */
+#endif /* DEBUG */
+
+int
+#if STDC
+main(int argc, char *argv[])
+#else
+main(argc, argv)
+int argc;
+char *argv[];
+#endif
+{
+ char *fns[ARRAY_MAX];
+ char *ap;
+ int use_stdin = FALSE;
+ int sty_given = FALSE;
+ int ind_given = FALSE;
+ int ilg_given = FALSE;
+ int log_given = FALSE;
+
+ /* determine program name */
+#if (OS_ATARI | OS_VAXVMS | OS_BS2000 | OS_MVSXA | OS_VMCMS)
+ pgm_fn = "MakeIndex"; /* Use symbolic name on some systems */
+#else
+ pgm_fn = strrchr(*argv, DIR_DELIM);
+ if (pgm_fn == NULL)
+ pgm_fn = *argv;
+ else
+ pgm_fn++;
+
+#if OS_PCDOS
+ {
+ register char *ext = pgm_fn + strlen(pgm_fn)-4;
+ if ( *ext == '.' )
+ *ext = NUL; /* cut off ".EXE" */
+ }
+ (void)strlwr(pgm_fn); /* lower program name */
+#endif /* OS_PCDOS */
+
+#endif /* OS_VAXVMS | OS_BS2000 | OS_MVSXA */
+
+ /* process command line options */
+ while (--argc > 0) {
+ if (**++argv == SW_PREFIX) {
+ if (*(*argv + 1) == NUL)
+ break;
+ for (ap = ++*argv; *ap != NUL; ap++)
+#if (OS_BS2000 | OS_MVSXA | OS_VAXVMS)
+ switch (tolower(*ap)) {
+#else
+ switch (*ap) {
+#endif /* (OS_BS2000 | OS_MVSXA | OS_VAXVMS) */
+
+ /* use standard input */
+ case 'i':
+ use_stdin = TRUE;
+ break;
+
+ /* enable letter ordering */
+ case 'l':
+ letter_ordering = TRUE;
+ break;
+
+ /* disable range merge */
+ case 'r':
+ merge_page = FALSE;
+ break;
+
+ /* supress progress message -- quiet mode */
+ case 'q':
+ verbose = FALSE;
+ break;
+
+ /* compress blanks */
+ case 'c':
+ compress_blanks = TRUE;
+ break;
+
+ /* style file */
+ case 's':
+ argc--;
+ if (argc <= 0)
+ FATAL("Expected -s <stylefile>\n","");
+ open_sty(*++argv);
+ sty_given = TRUE;
+ break;
+
+ /* output index file name */
+ case 'o':
+ argc--;
+ if (argc <= 0)
+ FATAL("Expected -o <ind>\n","");
+ ind_fn = *++argv;
+ ind_given = TRUE;
+ break;
+
+ /* transcript file name */
+ case 't':
+ argc--;
+ if (argc <= 0)
+ FATAL("Expected -t <logfile>\n","");
+ ilg_fn = *++argv;
+ ilg_given = TRUE;
+ break;
+
+ /* initial page */
+ case 'p':
+ argc--;
+ if (argc <= 0)
+ FATAL("Expected -p <num>\n","");
+ strcpy(pageno, *++argv);
+ init_page = TRUE;
+ if (STREQ(pageno, EVEN)) {
+ log_given = TRUE;
+ even_odd = 2;
+ } else if (STREQ(pageno, ODD)) {
+ log_given = TRUE;
+ even_odd = 1;
+ } else if (STREQ(pageno, ANY)) {
+ log_given = TRUE;
+ even_odd = 0;
+ }
+ break;
+
+ /* enable german sort */
+ case 'g':
+ german_sort = TRUE;
+ break;
+
+ /* bad option */
+ default:
+ FATAL("Unknown option -%c.\n", *ap);
+ break;
+ }
+ } else {
+ if (fn_no < ARRAY_MAX) {
+ check_idx(*argv, FALSE);
+ fns[++fn_no] = *argv;
+ } else {
+ FATAL("Too many input files (max %d).\n", ARRAY_MAX);
+ }
+ }
+ }
+
+/* changes for 2.12 (May 20, 1993) by Julian Reschke (jr@ms.maus.de):
+ if only one input file and no explicit style file was given */
+#if OS_BS2000
+/* not supported */
+#else
+ if (fn_no == 0 && !sty_given)
+ {
+ char tmp[STRING_MAX + 5];
+
+ /* base set by last call to check_idx */
+ sprintf (tmp, "%s%s", base, INDEX_STY);
+ if (0 == access(tmp, R_OK)) {
+ open_sty (tmp);
+ sty_given = TRUE;
+ }
+ }
+#endif
+
+ process_idx(fns, use_stdin, sty_given, ind_given, ilg_given, log_given);
+ idx_gt = idx_tt - idx_et;
+ ALL_DONE;
+ if (idx_gt > 0) {
+ prepare_idx();
+ sort_idx();
+ gen_ind();
+ MESSAGE("Output written in %s.\n", ind_fn);
+ } else
+ MESSAGE("Nothing written in %s.\n", ind_fn);
+
+ MESSAGE("Transcript written in %s.\n", ilg_fn);
+ CLOSE(ind_fp);
+ CLOSE(ilg_fp);
+ EXIT(0);
+
+ return (0); /* never executed--avoids complaints */
+ /* about no return value */
+}
+
+
+static void
+prepare_idx(VOID_ARG)
+{
+ NODE_PTR ptr = head;
+ int i = 0;
+
+#ifdef DEBUG
+ totmem += idx_gt * sizeof(FIELD_PTR);
+ (void)fprintf(stderr,"prepare_idx(): calloc(%d,%d)\ttotmem = %ld\n",
+ idx_gt,sizeof(FIELD_PTR),totmem);
+#endif /* DEBUG */
+
+ if (head == (NODE_PTR)NULL)
+ FATAL("No valid index entries collected.\n", "");
+
+ if ((idx_key = (FIELD_PTR *) calloc(idx_gt, sizeof(FIELD_PTR))) == NULL) {
+ FATAL("Not enough core...abort.\n", "");
+ }
+ for (i = 0; i < idx_gt; i++) {
+ idx_key[i] = &(ptr->data);
+ ptr = ptr->next;
+ }
+}
+
+
+static void
+#if STDC
+process_idx(char *fn[], int use_stdin, int sty_given, int ind_given,
+ int ilg_given, int log_given)
+#else
+process_idx(fn, use_stdin, sty_given, ind_given, ilg_given, log_given)
+char *fn[];
+int use_stdin;
+int sty_given;
+int ind_given;
+int ilg_given;
+int log_given;
+#endif
+{
+ int i;
+
+ if (fn_no == -1)
+ /* use stdin if no input files specified */
+ use_stdin = TRUE;
+ else {
+ check_all(fn[0], ind_given, ilg_given, log_given);
+ PUT_VERSION;
+ if (sty_given)
+ scan_sty();
+ if (german_sort && (idx_quote == '"'))
+FATAL("Option -g invalid, quote character must be different from '%c'.\n",
+'"');
+ scan_idx();
+ ind_given = TRUE;
+ ilg_given = TRUE;
+ for (i = 1; i <= fn_no; i++) {
+ check_idx(fn[i], TRUE);
+ scan_idx();
+ }
+ }
+
+ if (use_stdin) {
+ idx_fn = "stdin";
+ idx_fp = stdin;
+
+ if (ind_given) {
+ if (!ind_fp && ((ind_fp = OPEN_OUT(ind_fn)) == NULL))
+ FATAL("Can't create output index file %s.\n", ind_fn);
+ } else {
+ ind_fn = "stdout";
+ ind_fp = stdout;
+ }
+
+ if (ilg_given) {
+ if (!ilg_fp && ((ilg_fp = OPEN_OUT(ilg_fn)) == NULL))
+ FATAL("Can't create transcript file %s.\n", ilg_fn);
+ } else {
+ ilg_fn = "stderr";
+ ilg_fp = stderr;
+ }
+
+ if ((fn_no == -1) && (sty_given))
+ scan_sty();
+ if (german_sort && (idx_quote == '"'))
+FATAL("Option -g ignored, quote character must be different from '%c'.\n",
+'"');
+
+ if (need_version) {
+ PUT_VERSION;
+ }
+ scan_idx();
+ fn_no++;
+ }
+}
+
+
+static void
+#if STDC
+check_idx(char *fn, int open_fn)
+#else
+check_idx(fn, open_fn)
+char *fn;
+int open_fn;
+#endif
+{
+ char *ptr = fn;
+ char *ext;
+ int with_ext = FALSE;
+ int i = 0;
+
+#if OS_BS2000
+ char message[256]; /* error message */
+ char arg[8]; /* argument for sprintf() */
+
+ ext = strrchr(fn, EXT_DELIM);
+ if ((ext != NULL) &&
+ (((*fn == CATID) && (*(fn + 3) != DIR_DELIM)) ||
+ (((*fn == DIR_DELIM) || (*fn == CATID)) &&
+ (strchr(fn, EXT_DELIM) < ext)))) {
+#else
+ ext = strrchr(fn, EXT_DELIM);
+ if ((ext != NULL) && (ext != fn) && (*(ext + 1) != DIR_DELIM)) {
+#endif /* OS_BS2000 */
+ with_ext = TRUE;
+ while ((ptr != ext) && (i < STRING_MAX))
+ base[i++] = *ptr++;
+ } else
+ while ((*ptr != NUL) && (i < STRING_MAX))
+ base[i++] = *ptr++;
+
+ if (i < STRING_MAX)
+ base[i] = NUL;
+ else
+ FATAL2("Index file name %s too long (max %d).\n",
+ base, STRING_MAX);
+
+ idx_fn = fn;
+
+#if OS_BS2000 /* Search both on HOME-PVS and
+ * WORK-PVS */
+ sprintf(widx_fn, "%s%s", WORK, idx_fn);
+ if (((((idx_fp = OPEN_IN(idx_fn)) == NULL) && open_fn) ||
+ !(open_fn || idx_fp)) &&
+ ((((widx_fp = OPEN_IN(widx_fn)) == NULL) && open_fn) ||
+ !(open_fn || widx_fp)))
+ if (with_ext) {
+ sprintf(message, "Input index file %s%%s not found.\n",
+ (strchr(idx_fn, ':') || (strlen(WORK) == 0)) ?
+ NIL : "<" WORK ">");
+ FATAL(message, idx_fn);
+ } else {
+
+#ifdef DEBUG
+ totmem += STRING_MAX;
+ (void)fprintf(stderr,"check_idx()-1: malloc(%d)\ttotmem = %ld\n",
+ STRING_MAX,totmem);
+#endif /* DEBUG */
+
+ if ((idx_fn = (char *) malloc(STRING_MAX)) == NULL)
+ FATAL("Not enough core...abort.\n", "");
+ sprintf(idx_fn, "%s%s", base, INDEX_IDX);
+ sprintf(widx_fn, "%s%s%s", WORK, base, INDEX_IDX);
+ if (((((idx_fp = OPEN_IN(idx_fn)) == NULL) && open_fn) ||
+ !(open_fn || idx_fp)) &&
+ ((((widx_fp = OPEN_IN(widx_fn)) == NULL) && open_fn) ||
+ !(open_fn || widx_fp))) {
+ sprintf(arg, "%s",
+ (strchr(idx_fn, ':') || (strlen(WORK) == 0)) ?
+ NIL : "<" WORK ">");
+ sprintf(message,
+ "Couldn't find neither input file %s%%s nor %s%%s.\n",
+ arg, arg);
+ FATAL2(message, base, idx_fn);
+ }
+ }
+ if (!open_fn) { /* Close files if open */
+ if (idx_fp)
+ FCLOSE(idx_fp);
+ if (widx_fp)
+ FCLOSE(widx_fp);
+ }
+ if (open_fn && (!idx_fp) && widx_fp) { /* File was found on PVS W */
+ idx_fp = widx_fp;
+ idx_fn = widx_fn;
+ }
+#else /* NOT OS_BS2000 */
+ if ( ( open_fn &&
+ ((idx_fp = OPEN_IN(idx_fn)) == NULL)
+ ) ||
+ ((!open_fn) && (access(idx_fn, R_OK) != 0)))
+ if (with_ext) {
+ FATAL("Input index file %s not found.\n", idx_fn);
+ } else {
+
+#ifdef DEBUG
+ totmem += STRING_MAX;
+ (void)fprintf(stderr,"check_idx()-2: malloc(%d)\ttotmem = %ld\n",
+ STRING_MAX,totmem);
+#endif /* DEBUG */
+
+ if ((idx_fn = (char *) malloc(STRING_MAX)) == NULL)
+ FATAL("Not enough core...abort.\n", "");
+ sprintf(idx_fn, "%s%s", base, INDEX_IDX);
+ if ((open_fn &&
+ ((idx_fp = OPEN_IN(idx_fn)) == NULL)
+ ) ||
+ ((!open_fn) && (access(idx_fn, R_OK) != 0))) {
+ FATAL2("Couldn't find input index file %s nor %s.\n", base,
+ idx_fn);
+ }
+ }
+#endif /* OS_BS2000 */
+}
+
+
+static void
+#if STDC
+check_all(char *fn, int ind_given, int ilg_given, int log_given)
+#else
+check_all(fn, ind_given, ilg_given, log_given)
+char *fn;
+int ind_given;
+int ilg_given;
+int log_given;
+#endif
+{
+ check_idx(fn, TRUE);
+
+ /* index output file */
+ if (!ind_given) {
+ sprintf(ind, "%s%s", base, INDEX_IND);
+ ind_fn = ind;
+#if OS_BS2000 /* Look on HOME-, then WORK-PVS */
+ if ((ind_fp = OPEN_IN(ind_fn)) == NULL) {
+ sprintf(ind, "%s%s%s", strchr(base, ':') ?
+ NIL : WORK, base, INDEX_IND);
+ ind_fn = ind;
+ } else
+ fclose(ind_fp);
+#endif /* OS_BS2000 */
+ }
+ if ((ind_fp = OPEN_OUT(ind_fn)) == NULL)
+ FATAL("Can't create output index file %s.\n", ind_fn);
+
+ /* index transcript file */
+ if (!ilg_given) {
+ sprintf(ilg, "%s%s", base, INDEX_ILG);
+ ilg_fn = ilg;
+#if OS_BS2000 /* Look on HOME-, then WORK-PVS */
+ if ((ilg_fp = OPEN_IN(ilg_fn)) == NULL) {
+ sprintf(ilg, "%s%s%s", strchr(base, ':') ?
+ NIL : WORK, base, INDEX_ILG);
+ ilg_fn = ilg;
+ } else
+ fclose(ilg_fp);
+#endif /* OS_BS2000 */
+ }
+ if ((ilg_fp = OPEN_OUT(ilg_fn)) == NULL)
+ FATAL("Can't create transcript file %s.\n", ilg_fn);
+
+#if OS_BS2000 /* Search both on HOME-PVS ans
+ * WORK-PVS */
+ if (log_given) {
+ sprintf(log_fn, "%s%s%s", strchr(base, ':') ? NIL : WORK,
+ base, INDEX_LOG);
+ if ((log_fp = OPEN_IN(log_fn)) == NULL) {
+ if (strchr(base, ':'))
+ sprintf(log_fn, "%s%s", strrchr(base, ':') + 1, INDEX_LOG);
+ else
+ sprintf(log_fn, "%s%s", base, INDEX_LOG);
+ if ((log_fp = OPEN_IN(log_fn)) == NULL)
+ FATAL2("Source log file %s%s not found.\n", WORK, log_fn);
+ } else {
+ find_pageno();
+ CLOSE(log_fp);
+ }
+ }
+#else
+ if (log_given) {
+ sprintf(log_fn, "%s%s", base, INDEX_LOG);
+#if OS_PCDOS /* open in binary mode (CR-LF) */
+ if ((log_fp = OPEN_IN_B(log_fn)) == NULL) {
+#else
+ if ((log_fp = OPEN_IN(log_fn)) == NULL) {
+#endif /* OS_PCDOS */
+ FATAL("Source log file %s not found.\n", log_fn);
+ } else {
+ find_pageno();
+ CLOSE(log_fp);
+ }
+ }
+#endif /* OS_BS2000 */
+}
+
+
+static void
+find_pageno(VOID_ARG)
+{
+ int i = 0;
+ int p, c;
+
+#if (OS_VAXVMS | OS_BS2000 | OS_MVSXA)
+ /*
+ * Scan forward through the file for VMS, because fseek doesn't work on
+ * variable record files
+ */
+ c = GET_CHAR(log_fp);
+ while (c != EOF) {
+ p = c;
+ c = GET_CHAR(log_fp);
+ if (p == LSQ && isdigit(c)) {
+ i = 0;
+ do {
+ pageno[i++] = c;
+ c = GET_CHAR(log_fp);
+ } while (isdigit(c));
+ pageno[i] = NUL;
+ }
+ }
+ if (i == 0) {
+ fprintf(ilg_fp, "Couldn't find any page number in %s...ignored\n",
+ log_fn);
+ init_page = FALSE;
+ }
+#else /* NOT (OS_VAXVMS | ...) */
+ fseek(log_fp, -1L, 2);
+ p = GET_CHAR(log_fp);
+ fseek(log_fp, -2L, 1);
+ do {
+ c = p;
+ p = GET_CHAR(log_fp);
+ } while (!(((p == LSQ) && isdigit(c)) || (fseek(log_fp, -2L, 1) != 0)));
+ if (p == LSQ) {
+ while ((c = GET_CHAR(log_fp)) == SPC);
+ do {
+ pageno[i++] = (char) c;
+ c = GET_CHAR(log_fp);
+ } while (isdigit(c));
+ pageno[i] = NUL;
+ } else {
+ fprintf(ilg_fp, "Couldn't find any page number in %s...ignored\n",
+ log_fn);
+ init_page = FALSE;
+ }
+#endif /* (OS_VAXVMS | ...) */
+}
+
+static void
+#if STDC
+open_sty(char *fn)
+#else
+open_sty(fn)
+char *fn;
+#endif
+{
+ char *path;
+ char *ptr;
+ int i;
+ int len;
+
+ if ((path = getenv(STYLE_PATH)) == NULL) {
+ /* style input path not defined */
+ strcpy(sty_fn, fn);
+ sty_fp = OPEN_IN(sty_fn);
+ } else {
+#if OS_VAXVMS
+ if ((strlen(STYLE_PATH) + strlen(fn) + 1) > ARRAY_MAX) {
+ FATAL2("Path %s too long (max %d).\n", STYLE_PATH, ARRAY_MAX);
+ } else {
+ sprintf(sty_fn, "%s:%s", STYLE_PATH, fn);
+ sty_fp = OPEN_IN(sty_fn);
+ }
+#else /* NOT OS_VAXVMS */
+ len = ARRAY_MAX - strlen(fn) - 1;
+ while (*path != NUL) {
+#if OS_XENIX
+ i = 0;
+ while ((*path != ENV_SEPAR) && (*path != NUL) && (i < len))
+ sty_fn[i++] = *path++;
+#else /* NOT OS_XENIX */
+ ptr = strchr(path, ENV_SEPAR);
+ i = 0;
+ if (ptr == (char*)NULL)
+ {
+ int j = strlen(path);
+
+ while (i < j)
+ sty_fn[i++] = *path++;
+ }
+ else
+ {
+ while ((path != ptr) && (i < len))
+ sty_fn[i++] = *path++;
+ }
+#endif /* OS_XENIX */
+ if (i == len) {
+ FATAL2("Path %s too long (max %d).\n", sty_fn, ARRAY_MAX);
+ } else {
+#ifdef OS_VAXVMS
+ if (sty_fn[i-1] != ']')
+ sty_fn[i++] = DIR_DELIM;
+#else
+ sty_fn[i++] = DIR_DELIM;
+#endif
+ sty_fn[i] = NUL;
+ strcat(sty_fn, fn);
+#if OS_XENIX
+ if (((sty_fp = OPEN_IN(sty_fn)) == NULL) && (*path != NUL))
+#else /* NOT OS_XENIX */
+ if ((sty_fp = OPEN_IN(sty_fn)) == NULL)
+#endif /* OS_XENIX */
+ path++;
+ else
+ break;
+ }
+ }
+#endif /* OS_VAXVMS */
+ }
+
+ if (sty_fp == NULL)
+ FATAL("Index style file %s not found.\n", fn);
+}
+
+
+int
+#if STDC
+strtoint(char *str)
+#else
+strtoint(str)
+char *str;
+#endif
+{
+ int val = 0;
+
+ while (*str != NUL) {
+#if (OS_BS2000 | OS_MVSXA)
+ val = 10 * val + *str - '0';
+#else
+ val = 10 * val + *str - 48;
+#endif /* (OS_BS2000 | OS_MVSXA) */
+ str++;
+ }
+ return (val);
+}
diff --git a/indexing/makeindex/src/mkind.h b/indexing/makeindex/src/mkind.h
new file mode 100644
index 0000000000..86f5ad884d
--- /dev/null
+++ b/indexing/makeindex/src/mkind.h
@@ -0,0 +1,757 @@
+/*
+ *
+ * This file is part of
+ * MakeIndex - A formatter and format independent index processor
+ *
+ * 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
+ *
+ * Author:
+ * Pehong Chen
+ * Chen & Harrison International Systems, Inc.
+ * Palo Alto, California
+ * USA
+ * (phc@renoir.berkeley.edu or chen@orc.olivetti.com)
+ *
+ * Contributors:
+ * Please refer to the CONTRIB file that comes with this release
+ * for a list of people who have contributed to this and/or previous
+ * release(s) of MakeIndex.
+ *
+ * All rights reserved by the copyright holders. See the copyright
+ * notice distributed with this software for a complete description of
+ * the conditions under which it is made available.
+ *
+ */
+
+/***********************************************************************
+
+ INSTALLATION NOTES
+ <11-Nov-1989>
+
+ At compile-time (or here, if compile-time definition is not
+ available), set non-zero ONE OS_xxxx operating system flag, and if
+ more than one compiler is available, ONE compiler flag:
+
+ Operating Systems Compiler(s)
+ ================= ===========
+ OS_ATARI
+ OS_BS2000 CCD_2000
+ OS_BSD
+ OS_MVSXA IBM_C370
+ OS_VMCMS IBM_C370
+ OS_PCDOS IBM_PC_MICROSOFT
+ OS_SYSV
+ OS_TOPS20 KCC_20 or PCC_20
+ OS_VAXVMS
+ OS_XENIX
+ ================= ===========
+
+ If no OS_xxxx symbol is defined, OS_BSD is assumed.
+
+ If Standard C prototypes are supported, define the symbol
+ STDC_PROTOTYPES in the appropriate OS_xxxx section below, and insert
+ #include's for the standard system files which define library
+ prototypes. STDC_PROTOTYPES will be defined automatically if
+ __STDC__ is; the latter must be defined by all Standard C conformant
+ implementations.
+
+ All function declarations in MakeIndex are contained at the end of
+ this file. If 185STDC_PROTOTYPES is not selected, then all the standard
+ library functions must be declared explicitly.
+
+ If the host system restricts external names to 6 characters, set
+ SHORTNAMES non-zero in the appropriate OS_xxxx section below.
+
+ Installing MakeIndex under BS2000 requires at least Version 8.5
+ supporting Multiple Public Volume Sets (MPVS). Define WORK in this
+ file to your CATID (default :w:) for temporary files (.ilg, .ind),
+ in case of no MPVS support define WORK to NIL.
+
+*/
+
+/**********************************************************************/
+
+#define STDC (__STDC__ || __cplusplus)
+
+/*
+ * Establish needed operating symbols (defaulting to OS_BSD if none
+ * specified at compile time). If you add one, add it to the check
+ * list at the end of this section, too.
+ */
+
+#ifndef OS_ATARI
+#define OS_ATARI 0
+#endif
+
+#ifndef OS_PCDOS
+#define OS_PCDOS 0
+#endif
+
+#ifndef IBM_PC_MICROSOFT
+#define IBM_PC_MICROSOFT 0
+#endif
+
+#ifndef IBM_PC_TURBO
+#define IBM_PC_TURBO 0
+#endif
+
+#ifdef __TURBOC__
+#define IBM_PC_TURBO 1
+#endif
+
+#ifndef OS_SYSV
+#define OS_SYSV 0
+#endif
+
+#ifndef OS_TOPS20
+#define OS_TOPS20 0
+#endif
+
+#ifndef KCC_20
+#define KCC_20 0
+#endif
+
+#ifndef PCC_20
+#define PCC_20 0
+#endif
+
+#ifndef OS_BSD
+#define OS_BSD 0
+#endif
+
+#ifndef OS_VAXVMS
+#define OS_VAXVMS 0
+#endif
+
+#ifndef IBM_C370
+#define IBM_C370 0
+#endif
+
+#ifndef CCD_2000
+#define CCD_2000 0
+#endif
+
+#if OS_TOPS20
+#if (KCC_20 || PCC_20)
+#else
+#undef PCC_20
+#define PCC_20 1 /* PCC-20 is default for Tops-20 */
+#endif /* KCC_20 || PCC_20) */
+#endif /* OS_TOPS20 */
+
+#ifndef OS_BS2000
+#define OS_BS2000 0
+#endif
+
+#ifndef OS_MVSXA
+#define OS_MVSXA 0
+#endif
+
+#ifndef OS_VMCMS
+#define OS_VMCMS 0
+#endif
+
+#ifndef OS_XENIX
+#define OS_XENIX 0
+#endif
+
+#if (OS_ATARI || OS_BSD || OS_BS2000 || OS_MVSXA || OS_PCDOS || OS_VMCMS)
+#else
+#if (OS_SYSV || OS_TOPS20 || OS_VAXVMS || OS_XENIX)
+#else
+#undef OS_BSD
+#define OS_BSD 1 /* Unix is default operating system */
+#endif
+#endif
+
+#if (OS_MVSXA || OS_VMCMS)
+#undef IBM_C370
+#define IBM_C370 1 /* IBM_C370 is default for OS_MVSXA and OS_VMCMS */
+#endif
+
+#if OS_BS2000
+#undef CCD_2000
+#define CCD_2000 1 /* CCD_2000 is default for OS_BS2000 */
+#endif
+
+#if (CCD_2000 || OS_MVSXA || OS_TOPS20 || OS_VMCMS)
+#define SHORTNAMES 1
+#else
+#define SHORTNAMES 0
+#endif
+
+#define STDC_PROTOTYPES STDC
+
+/**********************************************************************/
+
+#include <stdio.h>
+#include <ctype.h>
+
+#if (CCD_2000 || OS_SYSV || OS_PCDOS || STDC || _AIX || ardent )
+#include <string.h>
+#else
+
+#if (OS_ATARI || OS_BSD || PCC_20 || OS_XENIX)
+#define strchr index /* convert STDC form to old K&R form */
+#define strrchr rindex /* convert STDC form to old K&R form */
+#endif /* (OS_ATARI || OS_BSD || PCC_20 || OS_XENIX) */
+
+#endif /* (CCD_2000 || OS_SYSV || OS_PCDOS || STDC || _AIX || ardent) */
+
+#if OS_PCDOS
+
+#if (IBM_PC_MICROSOFT || IBM_PC_TURBO)
+#include <io.h> /* for function declarations */
+#endif /* (IBM_PC_MICROSOFT || IBM_PC_TURBO) */
+
+#include <stddef.h> /* for function declarations */
+#include <stdlib.h> /* for function declarations */
+#undef STDC_PROTOTYPES
+#define STDC_PROTOTYPES 1 /* so we get full argument
+ type checking */
+#endif /* OS_PCDOS */
+
+#if (OS_VMCMS || OS_MVSXA)
+#include <stdefs.h> /* for function declarations */
+#include <string.h> /* for function declarations */
+#undef STDC_PROTOTYPES
+#define STDC_PROTOTYPES 1 /* so we get full argument
+ type checking */
+#if 0
+#undef __STDC__
+#define __STDC__ 1
+#endif
+#endif /* OS_MVSXA || OS_VMCMS */
+
+#if OS_ATARI
+
+#if ATARI_ST_TURBO
+#define access(fn, mode) 0 /* function not available */
+#endif
+
+#if __GNUC__
+#include <string.h>
+#include <types.h>
+#endif
+
+#undef STDC_PROTOTYPES
+#define STDC_PROTOTYPES 1 /* so we get full argument checking */
+
+#endif /* OS_ATARI */
+
+#if IBM_C370
+#define access(fn, mode) 0 /* function not available */
+#endif
+
+#if CCD_2000 /* function not available */
+#define getenv(P) 0
+#endif /* CCD_2000 */
+
+#if SHORTNAMES
+/*
+ * Provide alternate external names which are unique in the first SIX
+ * characters as required for portability (and Standard C)
+ */
+#define check_all chk_all
+#define check_idx chk_idx
+#define check_mixsym chk_mix
+#define compare_one cmp_one
+#define compare_page cmp_page
+#define compare_string cmp_string
+#define delim_n dlm_n
+#define delim_p dlm_p
+#define delim_r dlm_r
+#define delim_t dlm_t
+#define encap_i ecp_i
+#define encap_p ecp_p
+#define encap_range ecp_range
+#define encap_s ecp_s
+#define group_skip grp_skip
+#define group_type grp_type
+#define idx_aclose idxaclose
+#define idx_actual idxactual
+#define idx_keyword idx_kwd
+#define indent_length ind_length
+#define indent_space ind_space
+#define headings_flag hd_flag
+#define heading_pre hd_pre
+#define heading_suf hd_suf
+#define symhead_pos sym_pos
+#define symhead_neg sym_neg
+#define numhead_pos num_pos
+#define numhead_neg num_neg
+#define process_idx prc_idx
+#define process_precedence prc_pre
+#define range_ptr rng_ptr
+#define scan_alpha_lower scnalw
+#define scan_alpha_upper scnaup
+#define scan_arabic scnarabic
+#define scan_arg1 scna1
+#define scan_arg2 scna2
+#define scan_char scnchr
+#define scan_field scnfld
+#define scan_idx scnidx
+#define scan_key scnkey
+#define scan_no scnno
+#define scan_roman_lower scnrlw
+#define scan_roman_upper scnrup
+#define scan_spec scnspc
+#define scan_string scnstr
+#define scan_style scnsty
+#define setpagelen spg_len
+#define setpage_close spg_close
+#define setpage_open spg_open
+#define suffix_2p suf_2p
+#define suffix_3p suf_3p
+#define suffix_mp suf_mp
+#endif /* SHORTNAMES */
+
+#if OS_VAXVMS
+#define EXIT(code) exit( ((code) == 0) ? 1 : (1 << 28) + 2 )
+#else /* NOT OS_VAXVMS */
+#define EXIT exit
+#endif /* OS_VAXVMS */
+
+#undef TRUE
+#define TRUE 1
+
+#undef FALSE
+#define FALSE 0
+
+#undef NUL
+#define NUL '\0'
+
+#undef NIL
+#define NIL ""
+
+#define TAB '\t'
+#define LFD '\n'
+#define SPC ' '
+#define LSQ '['
+#define RSQ ']'
+#define BSH '\\'
+
+#if OS_ATARI
+#define ENV_SEPAR ';'
+#define DIR_DELIM '\\'
+#endif /* OS_ATARI */
+
+#if (OS_BSD || OS_SYSV || OS_XENIX)
+#define ENV_SEPAR ':'
+#define DIR_DELIM '/'
+#endif /* (OS_BSD || OS_SYSV || OS_XENIX)*/
+
+#if OS_BS2000
+#define ENV_SEPAR '#'
+#define DIR_DELIM '$'
+#endif /* OS_BS2000 */
+
+#if (OS_MVSXA || OS_VMCMS)
+#define ENV_SEPAR '.'
+#define DIR_DELIM '.'
+#endif /* OS_MVSXA || OS_VMCMS */
+
+#if OS_PCDOS
+#define ENV_SEPAR ';'
+#define DIR_DELIM '\\'
+#endif /* OS_PCDOS */
+
+#if OS_TOPS20
+#define ENV_SEPAR ','
+#define DIR_DELIM ':'
+#endif /* OS_TOPS20 */
+
+#if OS_BSD
+#define ENV_SEPAR ':'
+#define DIR_DELIM '/'
+#endif /* OS_BSD */
+
+#if OS_VAXVMS
+#define ENV_SEPAR ',' /* In fact these aren't used */
+#define DIR_DELIM ':'
+#endif /* OS_VAXVMS */
+
+#ifndef SW_PREFIX /* can override at compile time */
+#define SW_PREFIX '-'
+#endif
+
+#define EXT_DELIM '.'
+#define ROMAN_SIGN '*'
+#define EVEN "even"
+#define ODD "odd"
+#define ANY "any"
+
+#define GET_CHAR getc
+
+#if (CCD_2000 || OS_MVSXA)
+#define TOASCII(i) (char)((i) + '0')
+#else
+#define TOASCII(i) (char)((i) + 48)
+#endif /* (CCD_2000 || OS_MVSXA) */
+
+/* NB: The typecasts here are CRITICAL for correct sorting of entries
+ that use characters in the range 128..255! */
+#define TOLOWER(C) (isupper((unsigned char)(C)) ? \
+ (unsigned char)tolower((unsigned char)(C)) : (unsigned char)(C))
+#define TOUPPER(C) (isupper((unsigned char)(C)) ? \
+ (unsigned char)(C) : (unsigned char)toupper((unsigned char)(C)))
+
+#define STREQ(A, B) (strcmp(A, B) == 0)
+#define STRNEQ(A, B) (strcmp(A, B) != 0)
+
+#define MESSAGE(F, S) { \
+ if (verbose) \
+ fprintf(stderr, F, S); \
+ fprintf(ilg_fp, F, S); \
+}
+
+#define FATAL(F, S) { \
+ fprintf(stderr, F, S); \
+ fprintf(stderr, USAGE, pgm_fn); \
+ EXIT(1); \
+}
+
+#define FATAL2(F, D1, D2) { \
+ fprintf(stderr, F, D1, D2); \
+ fprintf(stderr, USAGE, pgm_fn); \
+ EXIT(1); \
+}
+
+#if OS_PCDOS /* open file in binary mode */
+#define OPEN_IN_B(FP) fopen(FP, "rb")
+#endif
+
+#define OPEN_IN(FP) fopen(FP, "r")
+#define OPEN_OUT(FP) fopen(FP, "w")
+#define CLOSE(FP) fclose(FP)
+
+#if (CCD_2000 || OS_MVSXA)
+#define ASCII 1
+#define ISDIGIT(C) isdigit(C)
+#define ISSYMBOL(C) (! (isdigit(C) || isalpha(C) || iscntrl(C) || C == SPC))
+#else
+#define ISDIGIT(C) ('0' <= C && C <= '9')
+#define ISSYMBOL(C) (('!' <= C && C <= '@') || \
+ ('[' <= C && C <= '`') || \
+ ('{' <= C && C <= '~'))
+#endif /* (CCD_2000 || OS_MVSXA) */
+
+/*====================================================================
+Many arrays in MakeIndex are dimensioned [xxx_MAX], where the xxx_MAX
+values are defined below. The use of each of these is described in
+comments. However, no run-time check is made to ensure that these are
+consistent, or reasonable! Therefore, change them only with great
+care.
+
+The array sizes should be made generously large: there are a great
+many uses of strings in MakeIndex with the strxxx() and sprintf()
+functions where no checking is done for adequate target storage sizes.
+Although some input checking is done to avoid this possibility, it is
+highly likely that there are still several places where storage
+violations are possible, with core dumps, or worse, incorrect output,
+ensuing.
+======================================================================*/
+
+#define ARABIC_MAX 5 /* maximum digits in an Arabic page */
+ /* number field */
+
+#define ARGUMENT_MAX 1024 /* maximum length of sort or actual key */
+ /* in index entry */
+
+#define ARRAY_MAX 1024 /* maximum length of constant values in */
+ /* style file */
+
+#define FIELD_MAX 3 /* maximum levels of index entries (item, */
+ /* subitem, subsubitem); cannot be */
+ /* increased beyond 3 without */
+ /* significant design changes (no field */
+ /* names are known beyond 3 levels) */
+
+#ifdef LINE_MAX /* IBM RS/6000 AIX has this in <sys/limits.h> */
+#undef LINE_MAX
+#endif
+#define LINE_MAX 72 /* maximum output line length (longer */
+ /* ones wrap if possible) */
+
+#define NUMBER_MAX 16 /* maximum digits in a Roman or Arabic */
+ /* page number */
+ /* (MAX(ARABIC_MAX,ROMAN_MAX)) */
+
+#define PAGEFIELD_MAX 10 /* maximum fields in a composite page */
+ /* number */
+
+#define PAGETYPE_MAX 5 /* fixed at 5; see use in scanst.c */
+
+#define ROMAN_MAX 16 /* maximum length of Roman page number */
+ /* field */
+
+#define STRING_MAX 256 /* maximum length of host filename */
+
+/*====================================================================*/
+
+#define VERSION "portable version 2.12 [26-May-1993]"
+
+#if 0
+#define VERSION "portable version 2.11 [19-Oct-1991]"
+#define VERSION "portable version 2.10 [05-Jul-1991]"
+#define VERSION "portable version 2.9.1 [21-Jun-1990]"
+#define VERSION "portable version 2.9 [13-Dec-1989]"
+#define VERSION "portable version 2.8 [11-Nov-1989]"
+#define VERSION "portable version 2.7 [01-Oct-1988]"
+#define VERSION "portable version 2.6 [14-Jul-1988]"
+#define VERSION "portable version 2.5 [14-Apr-1988]"
+#define VERSION "portable version 2.4 [20-Mar-1988]"
+#define VERSION "portable version 2.3 [20-Jan-1988]"
+#define VERSION "version 2.2 [29-May-1987]"
+#endif
+
+#define PUT_VERSION { \
+ MESSAGE("This is %s, ", pgm_fn); \
+ MESSAGE("%s.\n", VERSION); \
+ need_version = FALSE; \
+}
+
+#define USAGE \
+ "Usage: %s [-ilqrcg] [-s sty] [-o ind] [-t log] [-p num] [idx0 idx1 ...]\n"
+
+#define STYLE_PATH "INDEXSTYLE" /* environment variable defining search */
+ /* path for style files */
+#define INDEX_IDX ".idx"
+#define INDEX_ILG ".ilg"
+#define INDEX_IND ".ind"
+#define INDEX_STY ".mst"
+
+#if OS_VAXVMS
+#define INDEX_LOG ".lis"
+#else
+#define INDEX_LOG ".log"
+#endif
+
+#if OS_BS2000 /* Define WORK disk */
+#define WORK ":w:"
+#define CATID ':'
+#endif /* OS_BS2000 */
+
+#define EMPTY -9999
+#define ROML 0
+#define ROMU 1
+#define ARAB 2
+#define ALPL 3
+#define ALPU 4
+#define DUPLICATE 9999
+
+#define SYMBOL -1
+#define ALPHA -2
+
+#define GERMAN 0
+
+typedef struct KFIELD
+{
+ char *sf[FIELD_MAX]; /* sort key */
+ char *af[FIELD_MAX]; /* actual key */
+ int group; /* key group */
+ char lpg[NUMBER_MAX]; /* literal page */
+ short npg[PAGEFIELD_MAX]; /* page field array */
+ short count; /* page field count */
+ short type; /* page number type */
+ char *encap; /* encapsulator */
+ char *fn; /* input filename */
+ int lc; /* line number */
+} FIELD, *FIELD_PTR;
+
+typedef struct KNODE
+{
+ FIELD data;
+ struct KNODE *next;
+} NODE, *NODE_PTR;
+
+extern int letter_ordering;
+extern int compress_blanks;
+extern int init_page;
+extern int merge_page;
+extern int even_odd;
+extern int verbose;
+extern int german_sort;
+
+extern char idx_keyword[ARRAY_MAX];
+extern char idx_aopen;
+extern char idx_aclose;
+extern char idx_level;
+extern char idx_ropen;
+extern char idx_rclose;
+extern char idx_quote;
+extern char idx_actual;
+extern char idx_encap;
+extern char idx_escape;
+
+extern char page_comp[ARRAY_MAX];
+extern int page_offset[PAGETYPE_MAX];
+
+extern char preamble[ARRAY_MAX];
+extern char postamble[ARRAY_MAX];
+extern char setpage_open[ARRAY_MAX];
+extern char setpage_close[ARRAY_MAX];
+extern char group_skip[ARRAY_MAX];
+extern int headings_flag;
+extern char heading_pre[ARRAY_MAX];
+extern char heading_suf[ARRAY_MAX];
+extern char symhead_pos[ARRAY_MAX];
+extern char symhead_neg[ARRAY_MAX];
+extern char numhead_pos[ARRAY_MAX];
+extern char numhead_neg[ARRAY_MAX];
+extern int prelen;
+extern int postlen;
+extern int skiplen;
+extern int headprelen;
+extern int headsuflen;
+extern int setpagelen;
+
+extern char item_r[FIELD_MAX][ARRAY_MAX];
+extern char item_u[FIELD_MAX][ARRAY_MAX];
+extern char item_x[FIELD_MAX][ARRAY_MAX];
+extern int ilen_r[FIELD_MAX];
+extern int ilen_u[FIELD_MAX];
+extern int ilen_x[FIELD_MAX];
+
+extern char delim_p[FIELD_MAX][ARRAY_MAX];
+extern char delim_n[ARRAY_MAX];
+extern char delim_r[ARRAY_MAX];
+extern char delim_t[ARRAY_MAX];
+
+extern char suffix_2p[ARRAY_MAX];
+extern char suffix_3p[ARRAY_MAX];
+extern char suffix_mp[ARRAY_MAX];
+
+extern char encap_p[ARRAY_MAX];
+extern char encap_i[ARRAY_MAX];
+extern char encap_s[ARRAY_MAX];
+
+extern int linemax;
+extern char indent_space[ARRAY_MAX];
+extern int indent_length;
+
+extern FILE *idx_fp;
+extern FILE *sty_fp;
+extern FILE *ind_fp;
+extern FILE *ilg_fp;
+
+#if OS_BS2000
+extern FILE *widx_fp;
+extern char widx_fn[STRING_MAX + 5];
+#endif /* OS_BS2000 */
+
+extern char *idx_fn;
+extern char *pgm_fn;
+extern char *ind_fn;
+extern char *ilg_fn;
+
+#ifndef MKIND_C
+extern char sty_fn[];
+extern char ind[];
+extern char ilg[];
+extern char pageno[];
+
+#ifdef DEBUG
+extern long totmem;
+#endif /* DEBUG */
+
+#endif
+
+extern FIELD_PTR *idx_key;
+extern NODE_PTR head;
+extern NODE_PTR tail;
+
+extern int idx_dot;
+extern int idx_tt;
+extern int idx_gt;
+extern int idx_et;
+extern int idx_dc;
+
+#define DOT "."
+#define DOT_MAX 1000
+#define CMP_MAX 1500
+
+#define IDX_DOT(MAX) { \
+ idx_dot = TRUE; \
+ if (idx_dc++ == 0) { \
+ if (verbose) \
+ fprintf(stderr, DOT); \
+ fprintf(ilg_fp, DOT); \
+ } \
+ if (idx_dc == MAX) \
+ idx_dc = 0; \
+}
+
+#define ALL_DONE { \
+ if (fn_no > 0) { \
+ if (verbose) \
+fprintf(stderr, \
+ "Overall %d files read (%d entries accepted, %d rejected).\n", \
+ fn_no+1, idx_gt, idx_et); \
+fprintf(ilg_fp, \
+ "Overall %d files read (%d entries accepted, %d rejected).\n", \
+ fn_no+1, idx_gt, idx_et); \
+ } \
+}
+
+#define DONE(A, B, C, D) { \
+ if (verbose) \
+ fprintf(stderr, "done (%d %s, %d %s).\n", (A), B, C, D); \
+ fprintf(ilg_fp, "done (%d %s, %d %s).\n", (A), B, C, D); \
+}
+
+#if STDC_PROTOTYPES
+#define ARGS(arg_list) arg_list
+#define VOIDP void*
+#define VOID_ARG void
+#else
+#define ARGS(arg_list) ()
+#define const
+#define VOIDP char*
+#define VOID_ARG
+#endif
+
+extern void gen_ind ARGS((void));
+extern int group_type ARGS((char *str));
+extern int main ARGS((int argc, char **argv));
+extern void qqsort ARGS((char *base, int n, int size,
+ int (*compar)ARGS((char*,char*))));
+extern void scan_idx ARGS((void));
+extern void scan_sty ARGS((void));
+extern void sort_idx ARGS((void));
+extern int strtoint ARGS((char *str));
+
+#if STDC
+#include <stdlib.h>
+#undef strchr
+#undef strrchr
+#if __NeXT__
+int access ARGS((const char *, int));
+#else
+#include <unistd.h>
+#endif
+#else
+/* Miscellaneous standard library routines */
+int access ARGS((const char *, int));
+VOIDP calloc ARGS((size_t nitems,size_t size));
+
+#if CCD_2000 /* function not available */
+#define getenv(P) 0
+#else
+char *getenv ARGS((const char *name));
+#endif
+
+VOIDP malloc ARGS((size_t size));
+char *strchr ARGS((const char *s,int c));
+char *strrchr ARGS((const char *s,int c));
+#endif /* __STDC__ */
+
+#if PCC_20
+#define R_OK 0 /* PCC-20 access(file,mode) */
+#endif /* only understands mode=0 */
+
+#ifndef R_OK
+#define R_OK 4 /* only symbol from sys/file.h */
+#endif
diff --git a/indexing/makeindex/src/qsort.c b/indexing/makeindex/src/qsort.c
new file mode 100644
index 0000000000..7223a20545
--- /dev/null
+++ b/indexing/makeindex/src/qsort.c
@@ -0,0 +1,222 @@
+/*
+ *
+ * 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).
+ *
+ */
+
+/*
+ * qsort.c: Our own version of the system qsort routine which is faster by an
+ * average of 25%, with lows and highs of 10% and 50%. The THRESHold below is
+ * the insertion sort threshold, and has been adjusted for records of size 48
+ * 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 */
+
+#define THRESH 4 /* threshold for insertion */
+#define MTHRESH 6 /* threshold for median */
+
+static int qsz; /* size of each record */
+static int thresh; /* THRESHold in chars */
+static int mthresh; /* MTHRESHold in chars */
+
+static int (*qcmp) ARGS((char*,char*)); /* the comparison routine */
+static void qst ARGS((char *base, char *max));
+/*
+ * qqsort: First, set up some global parameters for qst to share. Then,
+ * quicksort with qst(), and then a cleanup insertion sort ourselves. Sound
+ * simple? It's not...
+ */
+
+void
+#if STDC
+qqsort(char *base, int n, int size, int (*compar) ARGS((char*,char*)))
+#else
+qqsort(base, n, size, compar)
+char *base;
+int n;
+int size;
+int (*compar) ARGS((char*,char*));
+#endif
+{
+ register char *i;
+ register char *j;
+ register char *lo;
+ register char *hi;
+ register char *min;
+ register char c;
+ char *max;
+
+ if (n <= 1)
+ return;
+ qsz = size;
+ qcmp = compar;
+ thresh = qsz * THRESH;
+ mthresh = qsz * MTHRESH;
+ max = base + n * qsz;
+ if (n >= THRESH) {
+ qst(base, max);
+ hi = base + thresh;
+ } else {
+ hi = max;
+ }
+ /*
+ * First put smallest element, which must be in the first THRESH, in the
+ * first position as a sentinel. This is done just by searching the
+ * first THRESH elements (or the first n if n < THRESH), finding the min,
+ * and swapping it into the first position.
+ */
+ for (j = lo = base; (lo += qsz) < hi;) {
+ if ((*qcmp) (j, lo) > 0)
+ j = lo;
+ }
+ if (j != base) { /* swap j into place */
+ for (i = base, hi = base + qsz; i < hi;) {
+ c = *j;
+ *j++ = *i;
+ *i++ = c;
+ }
+ }
+ /*
+ * With our sentinel in place, we now run the following hyper-fast
+ * insertion sort. For each remaining element, min, from [1] to [n-1],
+ * set hi to the index of the element AFTER which this one goes. Then, do
+ * the standard insertion sort shift on a character at a time basis for
+ * each element in the frob.
+ */
+ for (min = base; (hi = min += qsz) < max;) {
+ while ((*qcmp) (hi -= qsz, min) > 0);
+ if ((hi += qsz) != min) {
+ for (lo = min + qsz; --lo >= min;) {
+ c = *lo;
+ for (i = j = lo; (j -= qsz) >= hi; i = j)
+ *i = *j;
+ *i = c;
+ }
+ }
+ }
+}
+
+
+
+/*
+ * qst: Do a quicksort. First, find the median element, and put that one in
+ * the first place as the discriminator. (This "median" is just the median
+ * of the first, last and middle elements). (Using this median instead of
+ * the first element is a big win). Then, the usual partitioning/swapping,
+ * followed by moving the discriminator into the right place. Then, figure
+ * out the sizes of the two partions, do the smaller one recursively and the
+ * larger one via a repeat of this code. Stopping when there are less than
+ * THRESH elements in a partition and cleaning up with an insertion sort (in
+ * our caller) is a huge win. All data swaps are done in-line, which is
+ * space-losing but time-saving. (And there are only three places where this
+ * is done).
+ */
+
+static void
+#if STDC
+qst(char *base, char *max)
+#else
+qst(base, max)
+char *base;
+char *max;
+#endif
+{
+ register char *i;
+ register char *j;
+ register char *jj;
+ register char *mid;
+ register int ii;
+ register char c;
+ char *tmp;
+ int lo;
+ int hi;
+
+ lo = (int)(max - base); /* number of elements as chars */
+ do {
+ /*
+ * At the top here, lo is the number of characters of elements in the
+ * current partition. (Which should be max - base). Find the median
+ * of the first, last, and middle element and make that the middle
+ * element. Set j to largest of first and middle. If max is larger
+ * than that guy, then it's that guy, else compare max with loser of
+ * first and take larger. Things are set up to prefer the middle,
+ * then the first in case of ties.
+ */
+ mid = i = base + qsz * ((unsigned) (lo / qsz) >> 1);
+ if (lo >= mthresh) {
+ j = ((*qcmp) ((jj = base), i) > 0 ? jj : i);
+ if ((*qcmp) (j, (tmp = max - qsz)) > 0) {
+ /* switch to first loser */
+ j = (j == jj ? i : jj);
+ if ((*qcmp) (j, tmp) < 0)
+ j = tmp;
+ }
+ if (j != i) {
+ ii = qsz;
+ do {
+ c = *i;
+ *i++ = *j;
+ *j++ = c;
+ } while (--ii);
+ }
+ }
+ /* Semi-standard quicksort partitioning/swapping */
+ for (i = base, j = max - qsz;;) {
+ while (i < mid && (*qcmp) (i, mid) <= 0)
+ i += qsz;
+ while (j > mid) {
+ if ((*qcmp) (mid, j) <= 0) {
+ j -= qsz;
+ continue;
+ }
+ tmp = i + qsz; /* value of i after swap */
+ if (i == mid) { /* j <-> mid, new mid is j */
+ mid = jj = j;
+ } else { /* i <-> j */
+ jj = j;
+ j -= qsz;
+ }
+ goto swap;
+ }
+ if (i == mid) {
+ break;
+ } else { /* i <-> mid, new mid is i */
+ jj = mid;
+ tmp = mid = i; /* value of i after swap */
+ j -= qsz;
+ }
+ swap:
+ ii = qsz;
+ do {
+ c = *i;
+ *i++ = *jj;
+ *jj++ = c;
+ } while (--ii);
+ i = tmp;
+ }
+ /*
+ * Look at sizes of the two partitions, do the smaller one first by
+ * recursion, then do the larger one by making sure lo is its size,
+ * base and max are update correctly, and branching back. But only
+ * repeat (recursively or by branching) if the partition is of at
+ * least size THRESH.
+ */
+ i = (j = mid) + qsz;
+ if ((lo = (int)(j - base)) <= (hi = (int)(max - i))) {
+ if (lo >= thresh)
+ qst(base, j);
+ base = i;
+ lo = hi;
+ } else {
+ if (hi >= thresh)
+ qst(i, max);
+ max = j;
+ }
+ } while (lo >= thresh);
+}
diff --git a/indexing/makeindex/src/scanid.c b/indexing/makeindex/src/scanid.c
new file mode 100644
index 0000000000..4426110517
--- /dev/null
+++ b/indexing/makeindex/src/scanid.c
@@ -0,0 +1,830 @@
+/*
+ *
+ * This file is part of
+ * MakeIndex - A formatter and format independent index processor
+ *
+ * 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
+ *
+ * Author:
+ * Pehong Chen
+ * Chen & Harrison International Systems, Inc.
+ * Palo Alto, California
+ * USA
+ * (phc@renoir.berkeley.edu or chen@orc.olivetti.com)
+ *
+ * Contributors:
+ * Please refer to the CONTRIB file that comes with this release
+ * for a list of people who have contributed to this and/or previous
+ * release(s) of MakeIndex.
+ *
+ * All rights reserved by the copyright holders. See the copyright
+ * notice distributed with this software for a complete description of
+ * the conditions under which it is made available.
+ *
+ */
+
+#include "mkind.h"
+#include "scanid.h"
+
+#define CHECK_LENGTH() if (i > len_field) goto OVERFLOW
+
+int idx_lc; /* line count */
+int idx_tc; /* total entry count */
+int idx_ec; /* erroneous entry count */
+int idx_dc; /* number of dots printed so far */
+
+static int first_entry = TRUE;
+static int comp_len;
+static char key[ARGUMENT_MAX];
+static char no[NUMBER_MAX];
+extern char *strchr ARGS((const char* s,int c));
+
+NODE_PTR head;
+NODE_PTR tail;
+
+static void flush_to_eol ARGS((void));
+static int make_key ARGS((void));
+static void make_string ARGS((char **ppstr,int n));
+static int scan_alpha_lower ARGS((char *no,short *npg,short *count));
+static int scan_alpha_upper ARGS((char *no,short *npg,short *count));
+static int scan_arabic ARGS((char *no,short *npg,short *count));
+static int scan_arg1 ARGS((void));
+static int scan_arg2 ARGS((void));
+static int scan_field ARGS((int *n,char field[],int len_field,
+ int ck_level, int ck_encap,int ck_actual));
+static int scan_key ARGS((struct KFIELD *data));
+static int scan_no ARGS((char *no,short *npg,short *count,short *type));
+static int scan_roman_lower ARGS((char *no,short *npg,short *count));
+static int scan_roman_upper ARGS((char *no,short *npg,short *count));
+static void search_quote ARGS((char sort_key[],char actual_key[]));
+
+#if (OS_BS2000 | OS_MVSXA)
+char UPCC[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+#endif
+
+void
+scan_idx(VOID_ARG)
+{
+ char keyword[ARRAY_MAX];
+ int c;
+ int i = 0;
+ int not_eof = TRUE;
+ int arg_count = -1;
+
+ MESSAGE("Scanning input file %s...", idx_fn);
+ idx_lc = idx_tc = idx_ec = idx_dc = 0;
+ comp_len = strlen(page_comp);
+ while (not_eof) {
+ switch (c = GET_CHAR(idx_fp)) {
+ case EOF:
+ if (arg_count == 2) {
+ idx_lc++;
+ if (make_key())
+ IDX_DOT(DOT_MAX);
+ arg_count = -1;
+ } else
+ not_eof = FALSE;
+ break;
+
+ case LFD:
+ idx_lc++;
+ if (arg_count == 2) {
+ if (make_key())
+ IDX_DOT(DOT_MAX);
+ arg_count = -1;
+ } else if (arg_count > -1) {
+ IDX_ERROR("Missing arguments -- need two (premature LFD).\n",
+ NULL);
+ arg_count = -1;
+ }
+ case TAB:
+ case SPC:
+ break;
+
+ default:
+ switch (arg_count) {
+ case -1:
+ i = 0;
+ keyword[i++] = (char) c;
+ arg_count++;
+ idx_tc++;
+ break;
+ case 0:
+ if (c == idx_aopen) {
+ arg_count++;
+ keyword[i] = NUL;
+ if (STREQ(keyword, idx_keyword)) {
+ if (!scan_arg1()) {
+ arg_count = -1;
+ }
+ } else {
+ IDX_SKIPLINE;
+ IDX_ERROR("Unknown index keyword %s.\n", keyword);
+ }
+ } else {
+ if (i < ARRAY_MAX)
+ keyword[i++] = (char) c;
+ else {
+ IDX_SKIPLINE;
+ IDX_ERROR2("Index keyword %s too long (max %d).\n",
+ keyword, ARRAY_MAX);
+ }
+ }
+ break;
+ case 1:
+ if (c == idx_aopen) {
+ arg_count++;
+ if (!scan_arg2()) {
+ arg_count = -1;
+ }
+ } else {
+ IDX_SKIPLINE;
+IDX_ERROR(
+"No opening delimiter for second argument (illegal character `%c').\n", c);
+ }
+ break;
+ case 2:
+ IDX_SKIPLINE;
+IDX_ERROR(
+"No closing delimiter for second argument (illegal character `%c').\n", c);
+ break;
+ }
+ break;
+ }
+ }
+
+ /* fixup the total counts */
+ idx_tt += idx_tc;
+ idx_et += idx_ec;
+
+ DONE(idx_tc - idx_ec, "entries accepted", idx_ec, "rejected");
+ CLOSE(idx_fp);
+}
+
+static void
+flush_to_eol(VOID_ARG)
+{ /* flush to end-of-line, or end-of-file, whichever is first */
+ int a;
+
+ while ( ((a = GET_CHAR(idx_fp)) != LFD) && (a != EOF) )
+ /* NO-OP */;
+}
+
+static int
+make_key(VOID_ARG)
+{
+ NODE_PTR ptr;
+ int i;
+
+ /* allocate and initialize a node */
+
+#ifdef DEBUG
+ totmem += sizeof(NODE);
+ (void)fprintf(stderr,"make_key(): malloc(%d)\ttotmem = %ld\n",
+ sizeof(NODE),totmem);
+#endif /* DEBUG */
+
+ if ((ptr = (NODE_PTR) malloc(sizeof(NODE))) == NULL)
+ FATAL("Not enough core...abort.\n", "");
+
+ for (i = 0; i < FIELD_MAX; i++)
+ {
+ ptr->data.sf[i] = ""; /* initialize fields to pointers */;
+ ptr->data.af[i] = ""; /* to constant empty strings */
+ }
+ ptr->data.encap = "";
+ ptr->data.lpg[0] = NUL;
+ ptr->data.count = 0;
+ ptr->data.type = EMPTY;
+
+ /* process index key */
+ if (!scan_key(&(ptr->data)))
+ return (FALSE);
+
+ /* determine group type */
+ ptr->data.group = group_type(ptr->data.sf[0]);
+
+ /* process page number */
+ strcpy(ptr->data.lpg, no);
+ if (!scan_no(no, ptr->data.npg, &(ptr->data.count), &(ptr->data.type)))
+ return (FALSE);
+
+ if (first_entry) {
+ head = tail = ptr;
+ first_entry = FALSE;
+ } else {
+ tail->next = ptr;
+ tail = ptr;
+ }
+ ptr->data.lc = idx_lc;
+ ptr->data.fn = idx_fn;
+ tail->next = NULL;
+
+ return (TRUE);
+}
+
+static void
+#if STDC
+make_string(char **ppstr, int n)
+#else
+make_string(ppstr,n) /* allocate n-byte string if *ppstr */
+char **ppstr; /* points to an empty string */
+int n;
+#endif
+{
+ if ((*ppstr)[0] == NUL) /* then we have an empty string */
+ {
+ (*ppstr) = (char*)malloc(n);
+ if ((*ppstr) == (char*)NULL)
+ FATAL("Not enough core...abort.\n", "");
+ (*ppstr)[0] = NUL;
+ }
+}
+
+static int
+#if STDC
+scan_key(FIELD_PTR data)
+#else
+scan_key(data)
+FIELD_PTR data;
+#endif
+{
+ int i = 0; /* current level */
+ int n = 0; /* index to the key[] array */
+ int second_round = FALSE;
+ int last = FIELD_MAX - 1;
+
+ while (TRUE) {
+ if (key[n] == NUL)
+ break;
+ if (key[n] == idx_encap)
+ {
+ n++;
+ make_string(&(data->encap),strlen(key) + 1);
+ if (scan_field(&n, data->encap, strlen(key), FALSE, FALSE, FALSE))
+ break;
+ else
+ return (FALSE);
+ }
+ if (key[n] == idx_actual) {
+ n++;
+ if (i == last)
+ {
+ make_string(&(data->af[i]),strlen(key) + 1);
+ if (!scan_field(&n, data->af[i], strlen(key),
+ FALSE, TRUE, FALSE))
+ return (FALSE);
+ }
+ else
+ {
+ make_string(&(data->af[i]),strlen(key) + 1);
+ if (!scan_field(&n, data->af[i], strlen(key),
+ TRUE, TRUE, FALSE))
+ return (FALSE);
+ }
+ } else {
+ /* Next nesting level */
+ if (second_round) {
+ i++;
+ n++;
+ }
+ if (i == last)
+ {
+ make_string(&(data->sf[i]),strlen(key) + 1);
+ if (!scan_field(&n, data->sf[i], strlen(key),
+ FALSE, TRUE, TRUE))
+ return (FALSE);
+ }
+ else
+ {
+ make_string(&(data->sf[i]),strlen(key) + 1);
+ if (!scan_field(&n, data->sf[i], strlen(key),
+ TRUE, TRUE, TRUE))
+ return (FALSE);
+ }
+ second_round = TRUE;
+ if (german_sort && strchr(data->sf[i], '"'))
+ {
+ make_string(&(data->af[i]),strlen(data->sf[i]) + 1);
+ search_quote(data->sf[i], data->af[i]);
+ }
+ }
+ }
+
+ /* check for empty fields which shouldn't be empty */
+ if (*data->sf[0] == NUL) {
+ NULL_RTN;
+ }
+ for (i = 1; i < FIELD_MAX - 1; i++)
+ if ((*data->sf[i] == NUL) &&
+ ((*data->af[i] != NUL) || (*data->sf[i + 1] != NUL))) {
+ NULL_RTN;
+ }
+ /* i == FIELD_MAX-1 */
+ if ((*data->sf[i] == NUL) && (*data->af[i] != NUL)) {
+ NULL_RTN;
+ }
+ return (TRUE);
+}
+
+static int
+#if STDC
+scan_field(int *n, char field[], int len_field, int ck_level, int ck_encap,
+ int ck_actual)
+#else
+scan_field(n, field, len_field, ck_level, ck_encap, ck_actual)
+int *n;
+char field[];
+int len_field; /* length of field[], EXCLUDING space for final NUL */
+int ck_level;
+int ck_encap;
+int ck_actual;
+#endif
+{
+ int i = 0;
+ int nbsh; /* backslash count */
+
+ if (compress_blanks && ((key[*n] == SPC) || (key[*n] == TAB)))
+ ++* n;
+
+ while (TRUE) {
+ nbsh = 0;
+ while (key[*n] == idx_escape)
+ {
+ nbsh++;
+ field[i++] = key[*n];
+ CHECK_LENGTH();
+ ++*n;
+ }
+
+ if (key[*n] == idx_quote)
+ {
+ if (nbsh % 2 == 0)
+ field[i++] = key[++*n];
+ else
+ field[i++] = key[*n];
+ CHECK_LENGTH();
+ }
+ else if ((ck_level && (key[*n] == idx_level)) ||
+ (ck_encap && (key[*n] == idx_encap)) ||
+ (ck_actual && (key[*n] == idx_actual)) ||
+ (key[*n] == NUL))
+ {
+ if ((i > 0) && compress_blanks && (field[i - 1] == SPC))
+ field[i - 1] = NUL;
+ else
+ field[i] = NUL;
+ return (TRUE);
+ } else {
+ field[i++] = key[*n];
+ CHECK_LENGTH();
+ if ((!ck_level) && (key[*n] == idx_level)) {
+ IDX_ERROR2("Extra `%c' at position %d of first argument.\n",
+ idx_level, *n + 1);
+ return (FALSE);
+ } else if ((!ck_encap) && (key[*n] == idx_encap)) {
+ IDX_ERROR2("Extra `%c' at position %d of first argument.\n",
+ idx_encap, *n + 1);
+ return (FALSE);
+ } else if ((!ck_actual) && (key[*n] == idx_actual)) {
+ IDX_ERROR2("Extra `%c' at position %d of first argument.\n",
+ idx_actual, *n + 1);
+ return (FALSE);
+ }
+ }
+ /* check if max field length is reached */
+ if (i > len_field)
+ {
+ OVERFLOW:
+ if (!ck_encap) {
+ IDX_ERROR("Encapsulator of page number too long (max. %d).\n",
+ len_field);
+ } else if (ck_actual) {
+ IDX_ERROR("Index sort key too long (max. %d).\n", len_field);
+ } else {
+ IDX_ERROR("Text of key entry too long (max. %d).\n", len_field);
+ }
+ return (FALSE);
+ }
+ ++*n;
+ }
+#if IBM_PC_TURBO
+ return (FALSE); /* not reached, but keeps compiler happy */
+#endif
+}
+
+int
+#if STDC
+group_type(char *str)
+#else
+group_type(str)
+char *str;
+#endif
+{
+ int i = 0;
+
+ while ((str[i] != NUL) && ISDIGIT(str[i]))
+ i++;
+
+ if (str[i] == NUL) {
+ sscanf(str, "%d", &i);
+ return (i);
+ } else if (ISSYMBOL(str[0]))
+ return (SYMBOL);
+ else
+ return (ALPHA);
+}
+
+static int
+#if STDC
+scan_no(char no[], short npg[], short *count, short *type)
+#else
+scan_no(no, npg, count, type)
+char no[];
+short npg[];
+short *count;
+short *type;
+#endif
+{
+ int i = 1;
+
+ if (isdigit(no[0])) {
+ *type = ARAB;
+ if (!scan_arabic(no, npg, count))
+ return (FALSE);
+ /* simple heuristic to determine if a letter is Roman or Alpha */
+ } else if (IS_ROMAN_LOWER(no[0]) && (!IS_COMPOSITOR)) {
+ *type = ROML;
+ if (!scan_roman_lower(no, npg, count))
+ return (FALSE);
+ /* simple heuristic to determine if a letter is Roman or Alpha */
+ } else if (IS_ROMAN_UPPER(no[0]) &&
+ ((no[0] == ROMAN_I) || (!IS_COMPOSITOR))) {
+ *type = ROMU;
+ if (!scan_roman_upper(no, npg, count))
+ return (FALSE);
+ } else if (IS_ALPHA_LOWER(no[0])) {
+ *type = ALPL;
+ if (!scan_alpha_lower(no, npg, count))
+ return (FALSE);
+ } else if (IS_ALPHA_UPPER(no[0])) {
+ *type = ALPU;
+ if (!scan_alpha_upper(no, npg, count))
+ return (FALSE);
+ } else {
+ IDX_ERROR("Illegal page number %s.\n", no);
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+
+static int
+#if STDC
+scan_arabic(char no[], short npg[], short *count)
+#else
+scan_arabic(no, npg, count)
+char no[];
+short npg[];
+short *count;
+#endif
+{
+ short i = 0;
+ char str[ARABIC_MAX+1]; /* space for trailing NUL */
+
+ while ((no[i] != NUL) && (i <= ARABIC_MAX) && (!IS_COMPOSITOR)) {
+ if (isdigit(no[i])) {
+ str[i] = no[i];
+ i++;
+ } else {
+IDX_ERROR2("Illegal Arabic digit: position %d in %s.\n", i + 1, no);
+ return (FALSE);
+ }
+ }
+ if (i > ARABIC_MAX) {
+ IDX_ERROR2("Arabic page number %s too big (max %d digits).\n",
+ no, ARABIC_MAX);
+ return (FALSE);
+ }
+ str[i] = NUL;
+
+ ENTER(strtoint(str) + page_offset[ARAB]);
+
+ if (IS_COMPOSITOR)
+ return (scan_no(&no[i + comp_len], npg, count, &i));
+ else
+ return (TRUE);
+}
+
+
+static int
+#if STDC
+scan_roman_lower(char no[], short npg[], short *count)
+#else
+scan_roman_lower(no, npg, count)
+char no[];
+short npg[];
+short *count;
+#endif
+{
+ short i = 0;
+ int inp = 0;
+ int prev = 0;
+ int the_new;
+
+ while ((no[i] != NUL) && (i < ROMAN_MAX) && (!IS_COMPOSITOR)) {
+ if ((IS_ROMAN_LOWER(no[i])) &&
+ ((the_new = ROMAN_LOWER_VAL(no[i])) != 0)) {
+ if (prev == 0)
+ prev = the_new;
+ else {
+ if (prev < the_new) {
+ prev = the_new - prev;
+ the_new = 0;
+ }
+ inp += prev;
+ prev = the_new;
+ }
+ } else {
+IDX_ERROR2("Illegal Roman number: position %d in %s.\n", i + 1, no);
+ return (FALSE);
+ }
+ i++;
+ }
+ if (i == ROMAN_MAX) {
+ IDX_ERROR2("Roman page number %s too big (max %d digits).\n",
+ no, ROMAN_MAX);
+ return (FALSE);
+ }
+ inp += prev;
+
+ ENTER(inp + page_offset[ROML]);
+
+ if (IS_COMPOSITOR)
+ return (scan_no(&no[i + comp_len], npg, count, &i));
+ else
+ return (TRUE);
+}
+
+
+static int
+#if STDC
+scan_roman_upper(char no[], short npg[], short *count)
+#else
+scan_roman_upper(no, npg, count)
+char no[];
+short npg[];
+short *count;
+#endif
+{
+ short i = 0;
+ int inp = 0;
+ int prev = 0;
+ int the_new;
+
+ while ((no[i] != NUL) && (i < ROMAN_MAX) && (!IS_COMPOSITOR)) {
+ if ((IS_ROMAN_UPPER(no[i])) &&
+ ((the_new = ROMAN_UPPER_VAL(no[i])) != 0)) {
+ if (prev == 0)
+ prev = the_new;
+ else {
+ if (prev < the_new) {
+ prev = the_new - prev;
+ the_new = 0;
+ }
+ inp += prev;
+ prev = the_new;
+ }
+ } else {
+IDX_ERROR2("Illegal Roman number: position %d in %s.\n", i + 1, no);
+ return (FALSE);
+ }
+ i++;
+ }
+ if (i == ROMAN_MAX) {
+ IDX_ERROR2("Roman page number %s too big (max %d digits).\n",
+ no, ROMAN_MAX);
+ return (FALSE);
+ }
+ inp += prev;
+
+ ENTER(inp + page_offset[ROMU]);
+
+ if (IS_COMPOSITOR)
+ return (scan_no(&no[i + comp_len], npg, count, &i));
+ else
+ return (TRUE);
+}
+
+
+static int
+#if STDC
+scan_alpha_lower(char no[], short npg[], short *count)
+#else
+scan_alpha_lower(no, npg, count)
+char no[];
+short npg[];
+short *count;
+#endif
+{
+ short i;
+
+ ENTER(ALPHA_VAL(no[0]) + page_offset[ALPL]);
+
+ i = 1;
+ if (IS_COMPOSITOR)
+ return (scan_no(&no[comp_len + 1], npg, count, &i));
+ else
+ return (TRUE);
+}
+
+
+static int
+#if STDC
+scan_alpha_upper(char no[], short npg[], short *count)
+#else
+scan_alpha_upper(no, npg, count)
+char no[];
+short npg[];
+short *count;
+#endif
+{
+ short i;
+
+ ENTER(ALPHA_VAL(no[0]) + page_offset[ALPU]);
+
+ i = 1;
+ if (IS_COMPOSITOR)
+ return (scan_no(&no[comp_len + 1], npg, count, &i));
+ else
+ return (TRUE);
+}
+
+
+static int
+scan_arg1(VOID_ARG)
+{
+ int i = 0;
+ int n = 0; /* delimiter count */
+ int a;
+
+ if (compress_blanks)
+ while (((a = GET_CHAR(idx_fp)) == SPC) || (a == TAB));
+ else
+ a = GET_CHAR(idx_fp);
+
+ while ((i < ARGUMENT_MAX) && (a != EOF))
+ {
+ if ((a == idx_quote) || (a == idx_escape))
+ { /* take next character literally */
+ key[i++] = (char) a; /* but preserve quote or escape */
+ a = GET_CHAR(idx_fp);
+ key[i++] = (char) a; /* save literal character */
+ }
+ else if (a == idx_aopen)
+ { /* opening delimiters within the argument list */
+ key[i++] = (char) a;
+ n++;
+ }
+ else if (a == idx_aclose)
+ {
+ if (n == 0) /* end of argument */
+ {
+ if (compress_blanks && key[i - 1] == SPC)
+ key[i - 1] = NUL;
+ else
+ key[i] = NUL;
+ return (TRUE);
+ }
+ else /* nested delimiters */
+ {
+ key[i++] = (char) a;
+ n--;
+ }
+ }
+ else
+ {
+ switch (a)
+ {
+ case LFD:
+ idx_lc++;
+ IDX_ERROR("Incomplete first argument (premature LFD).\n", "");
+ return (FALSE);
+ case TAB:
+ case SPC:
+ /* compress successive SPC's to one SPC */
+ if (compress_blanks)
+ {
+ if ((i > 0) && (key[i - 1] != SPC) && (key[i - 1] != TAB))
+ key[i++] = SPC;
+ break;
+ }
+ default:
+ key[i++] = (char) a;
+ break;
+ }
+ }
+ a = GET_CHAR(idx_fp);
+ }
+
+ flush_to_eol(); /* Skip to end of line */
+ idx_lc++;
+ IDX_ERROR("First argument too long (max %d).\n", ARGUMENT_MAX);
+ return (FALSE);
+}
+
+
+static int
+scan_arg2(VOID_ARG)
+{
+ int i = 0;
+ int a;
+ int hit_blank = FALSE;
+
+ while (((a = GET_CHAR(idx_fp)) == SPC) || (a == TAB));
+
+ while (i < NUMBER_MAX) {
+ if (a == idx_aclose) {
+ no[i] = NUL;
+ return (TRUE);
+ } else
+ switch (a) {
+ case LFD:
+ idx_lc++;
+IDX_ERROR("Incomplete second argument (premature LFD).\n", "");
+ return (FALSE);
+ case TAB:
+ case SPC:
+ hit_blank = TRUE;
+ break;
+ default:
+ if (hit_blank) {
+ flush_to_eol(); /* Skip to end of line */
+ idx_lc++;
+IDX_ERROR("Illegal space within numerals in second argument.\n", "");
+ return (FALSE);
+ }
+ no[i++] = (char) a;
+ break;
+ }
+ a = GET_CHAR(idx_fp);
+ }
+ flush_to_eol(); /* Skip to end of line */
+ idx_lc++;
+ IDX_ERROR("Second argument too long (max %d).\n", NUMBER_MAX);
+ return (FALSE);
+}
+
+
+static void
+#if STDC
+search_quote(char sort_key[], char actual_key[])
+#else
+search_quote(sort_key, actual_key)
+char sort_key[];
+char actual_key[];
+#endif
+{
+ char *ptr; /* pointer to sort_key */
+ char *sort; /* contains sorting text */
+ int char_found = FALSE;
+
+ strcpy(actual_key, sort_key);
+ ptr = strchr(sort_key, '"'); /* look for first double quote */
+ while (ptr != (char*)NULL)
+ {
+ sort = "";
+ switch (*(ptr + 1))
+ { /* skip to umlaut or sharp S */
+ case 'a':
+ case 'A':
+ sort = isupper(*(ptr + 1)) ? "Ae" : "ae";
+ break;
+ case 'o':
+ case 'O':
+ sort = isupper(*(ptr + 1)) ? "Oe" : "oe";
+ break;
+ case 'u':
+ case 'U':
+ sort = isupper(*(ptr + 1)) ? "Ue" : "ue";
+ break;
+ case 's':
+ sort = "ss";
+ break;
+ default:
+ break;
+ }
+ if (sort[0] != NUL)
+ {
+ char_found = TRUE;
+ *ptr = sort[0]; /* write to sort_key */
+ *(ptr + 1) = sort[1];
+ }
+ ptr = strchr(ptr + 1, '"'); /* next double quote */
+ }
+ if (!char_found) /* reset actual_key ? */
+ actual_key[0] = NUL;
+ return;
+}
diff --git a/indexing/makeindex/src/scanid.h b/indexing/makeindex/src/scanid.h
new file mode 100644
index 0000000000..cd48b083c4
--- /dev/null
+++ b/indexing/makeindex/src/scanid.h
@@ -0,0 +1,170 @@
+/*
+ *
+ * This file is part of
+ * MakeIndex - A formatter and format independent index processor
+ *
+ * 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
+ *
+ * Author:
+ * Pehong Chen
+ * Chen & Harrison International Systems, Inc.
+ * Palo Alto, California
+ * USA
+ * (phc@renoir.berkeley.edu or chen@orc.olivetti.com)
+ *
+ * Contributors:
+ * Please refer to the CONTRIB file that comes with this release
+ * for a list of people who have contributed to this and/or previous
+ * release(s) of MakeIndex.
+ *
+ * All rights reserved by the copyright holders. See the copyright
+ * notice distributed with this software for a complete description of
+ * the conditions under which it is made available.
+ *
+ */
+
+#define IS_COMPOSITOR (strncmp(&no[i], page_comp, comp_len) == 0)
+
+#define ROMAN_I 'I'
+#define ROMAN_V 'V'
+#define ROMAN_X 'X'
+#define ROMAN_L 'L'
+#define ROMAN_C 'C'
+#define ROMAN_D 'D'
+#define ROMAN_M 'M'
+
+#define ROMAN_i 'i'
+#define ROMAN_v 'v'
+#define ROMAN_x 'x'
+#define ROMAN_l 'l'
+#define ROMAN_c 'c'
+#define ROMAN_d 'd'
+#define ROMAN_m 'm'
+
+#define VAL_I 1
+#define VAL_V 5
+#define VAL_X 10
+#define VAL_L 50
+#define VAL_C 100
+#define VAL_D 500
+#define VAL_M 1000
+
+#define ROMAN_LOWER_VAL(C) \
+ ((C == ROMAN_i) ? VAL_I : \
+ (C == ROMAN_v) ? VAL_V : \
+ (C == ROMAN_x) ? VAL_X : \
+ (C == ROMAN_l) ? VAL_L : \
+ (C == ROMAN_c) ? VAL_C : \
+ (C == ROMAN_d) ? VAL_D : \
+ (C == ROMAN_m) ? VAL_M : 0)
+
+#define ROMAN_UPPER_VAL(C) \
+ ((C == ROMAN_I) ? VAL_I : \
+ (C == ROMAN_V) ? VAL_V : \
+ (C == ROMAN_X) ? VAL_X : \
+ (C == ROMAN_L) ? VAL_L : \
+ (C == ROMAN_C) ? VAL_C : \
+ (C == ROMAN_D) ? VAL_D : \
+ (C == ROMAN_M) ? VAL_M : 0)
+
+#define IS_ROMAN_LOWER(C) \
+ ((C == ROMAN_i) || (C == ROMAN_v) || (C == ROMAN_x) || \
+ (C == ROMAN_l) || (C == ROMAN_c) || (C == ROMAN_d) || (C == ROMAN_m))
+
+#define IS_ROMAN_UPPER(C) \
+ ((C == ROMAN_I) || (C == ROMAN_V) || (C == ROMAN_X) || \
+ (C == ROMAN_L) || (C == ROMAN_C) || (C == ROMAN_D) || (C == ROMAN_M))
+
+#if (CCD_2000 | OS_MVSXA)
+#define ALPHA_VAL(C) ((isalpha(C)) ? (strchr(UPCC,toupper(C))-UPCC) : 0)
+
+#define IS_ALPHA_LOWER(C) (isalpha(C) && islower(C))
+
+#define IS_ALPHA_UPPER(C) (isalpha(C) && isupper(C))
+#else
+#define ALPHA_VAL(C) \
+ ((('A' <= C) && (C <= 'Z')) ? C - 'A' : \
+ (('a' <= C) && (C <= 'z')) ? C - 'a' : 0)
+
+#define IS_ALPHA_LOWER(C) \
+ (('a' <= C) && (C <= 'z'))
+
+#define IS_ALPHA_UPPER(C) \
+ (('A' <= C) && (C <= 'Z'))
+#endif /* CCD_2000 | OS_MVSXA */
+
+#define IDX_SKIPLINE { \
+ int tmp; \
+ while ((tmp = GET_CHAR(idx_fp)) != LFD) \
+ if (tmp == EOF) \
+ break; \
+ idx_lc++; \
+ arg_count = -1; \
+}
+
+#define NULL_RTN { \
+ IDX_ERROR("Illegal null field.\n", NULL); \
+ return (FALSE); \
+}
+
+#if KCC_20
+/* KCC preprocessor bug collapses multiple blanks to single blank */
+#define IDX_ERROR(F, D) { \
+ if (idx_dot) { \
+ fprintf(ilg_fp, "\n"); \
+ idx_dot = FALSE; \
+ } \
+ fprintf(ilg_fp, \
+ "!! Input index error (file = %s, line = %d):\n\040\040 -- ", \
+ idx_fn, idx_lc); \
+ fprintf(ilg_fp, F, D); \
+ idx_ec++; \
+}
+
+#define IDX_ERROR2(F, D1, D2) { \
+ if (idx_dot) { \
+ fprintf(ilg_fp, "\n"); \
+ idx_dot = FALSE; \
+ } \
+ fprintf(ilg_fp, \
+ "!! Input index error (file = %s, line = %d):\n\040\040 -- ", \
+ idx_fn, idx_lc); \
+ fprintf(ilg_fp, F, D1, D2); \
+ idx_ec++; \
+}
+#else
+#define IDX_ERROR(F, D) { \
+ if (idx_dot) { \
+ fprintf(ilg_fp, "\n"); \
+ idx_dot = FALSE; \
+ } \
+ fprintf(ilg_fp, "!! Input index error (file = %s, line = %d):\n -- ", \
+ idx_fn, idx_lc); \
+ fprintf(ilg_fp, F, D); \
+ idx_ec++; \
+}
+
+#define IDX_ERROR2(F, D1, D2) { \
+ if (idx_dot) { \
+ fprintf(ilg_fp, "\n"); \
+ idx_dot = FALSE; \
+ } \
+ fprintf(ilg_fp, "!! Input index error (file = %s, line = %d):\n -- ", \
+ idx_fn, idx_lc); \
+ fprintf(ilg_fp, F, D1, D2); \
+ idx_ec++; \
+}
+#endif
+
+
+#define ENTER(V) { \
+ if (*count >= PAGEFIELD_MAX) { \
+ IDX_ERROR2("Page number %s has too many fields (max. %d).", \
+ no, PAGEFIELD_MAX); \
+ return (FALSE); \
+ } \
+ npg[*count] = (V); \
+ ++*count; \
+}
diff --git a/indexing/makeindex/src/scanst.c b/indexing/makeindex/src/scanst.c
new file mode 100644
index 0000000000..ed3e9654d8
--- /dev/null
+++ b/indexing/makeindex/src/scanst.c
@@ -0,0 +1,616 @@
+/*
+ *
+ * This file is part of
+ * MakeIndex - A formatter and format independent index processor
+ *
+ * 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
+ *
+ * Author:
+ * Pehong Chen
+ * Chen & Harrison International Systems, Inc.
+ * Palo Alto, California
+ * USA
+ * (phc@renoir.berkeley.edu or chen@orc.olivetti.com)
+ *
+ * Contributors:
+ * Please refer to the CONTRIB file that comes with this release
+ * for a list of people who have contributed to this and/or previous
+ * release(s) of MakeIndex.
+ *
+ * All rights reserved by the copyright holders. See the copyright
+ * notice distributed with this software for a complete description of
+ * the conditions under which it is made available.
+ *
+ */
+
+#include "mkind.h"
+#include "scanst.h"
+
+static int sty_lc = 0; /* line count */
+static int sty_tc = 0; /* total count */
+static int sty_ec = 0; /* error count */
+
+char idx_keyword[ARRAY_MAX] = IDX_KEYWORD;
+char idx_aopen = IDX_AOPEN;
+char idx_aclose = IDX_ACLOSE;
+char idx_level = IDX_LEVEL;
+char idx_ropen = IDX_ROPEN;
+char idx_rclose = IDX_RCLOSE;
+char idx_quote = IDX_QUOTE;
+char idx_actual = IDX_ACTUAL;
+char idx_encap = IDX_ENCAP;
+char idx_escape = IDX_ESCAPE;
+
+char preamble[ARRAY_MAX] = PREAMBLE_DEF;
+char postamble[ARRAY_MAX] = POSTAMBLE_DEF;
+int prelen = PREAMBLE_LEN;
+int postlen = POSTAMBLE_LEN;
+
+char setpage_open[ARRAY_MAX] = SETPAGEOPEN_DEF;
+char setpage_close[ARRAY_MAX] = SETPAGECLOSE_DEF;
+int setpagelen = SETPAGE_LEN;
+
+char group_skip[ARRAY_MAX] = GROUPSKIP_DEF;
+int skiplen = GROUPSKIP_LEN;
+
+int headings_flag = HEADINGSFLAG_DEF;
+char heading_pre[ARRAY_MAX] = HEADINGPRE_DEF;
+char heading_suf[ARRAY_MAX] = HEADINGSUF_DEF;
+int headprelen = HEADINGPRE_LEN;
+int headsuflen = HEADINGSUF_LEN;
+
+char symhead_pos[ARRAY_MAX] = SYMHEADPOS_DEF;
+char symhead_neg[ARRAY_MAX] = SYMHEADNEG_DEF;
+
+char numhead_pos[ARRAY_MAX] = NUMHEADPOS_DEF;
+char numhead_neg[ARRAY_MAX] = NUMHEADNEG_DEF;
+
+char item_r[FIELD_MAX][ARRAY_MAX] = {ITEM0_DEF, ITEM1_DEF, ITEM2_DEF};
+char item_u[FIELD_MAX][ARRAY_MAX] = {"", ITEM1_DEF, ITEM2_DEF};
+char item_x[FIELD_MAX][ARRAY_MAX] = {"", ITEM1_DEF, ITEM2_DEF};
+
+int ilen_r[FIELD_MAX] = {ITEM_LEN, ITEM_LEN, ITEM_LEN};
+int ilen_u[FIELD_MAX] = {0, ITEM_LEN, ITEM_LEN};
+int ilen_x[FIELD_MAX] = {0, ITEM_LEN, ITEM_LEN};
+
+char delim_p[FIELD_MAX][ARRAY_MAX] = {DELIM_DEF, DELIM_DEF, DELIM_DEF};
+char delim_n[ARRAY_MAX] = DELIM_DEF; /* page number separator */
+char delim_r[ARRAY_MAX] = DELIMR_DEF;/* page range designator */
+char delim_t[ARRAY_MAX] = DELIMT_DEF;/* page list terminating delimiter */
+
+char suffix_2p[ARRAY_MAX] = ""; /* suffix for two page ranges */
+char suffix_3p[ARRAY_MAX] = ""; /* suffix for three page ranges */
+char suffix_mp[ARRAY_MAX] = ""; /* suffix for multiple page ranges */
+
+char encap_p[ARRAY_MAX] = ENCAP0_DEF;/* encapsulator prefix */
+char encap_i[ARRAY_MAX] = ENCAP1_DEF;/* encapsulator infix */
+char encap_s[ARRAY_MAX] = ENCAP2_DEF;/* encapsulator postfix */
+
+int linemax = LINE_MAX;
+
+int indent_length = INDENTLEN_DEF;
+char indent_space[ARRAY_MAX] = INDENTSPC_DEF;
+
+char page_comp[ARRAY_MAX] = COMPOSITOR_DEF;
+int page_offset[PAGETYPE_MAX] = {
+0,
+ROMAN_LOWER_OFFSET,
+ROMAN_LOWER_OFFSET + ARABIC_OFFSET,
+ROMAN_LOWER_OFFSET + ARABIC_OFFSET + ALPHA_LOWER_OFFSET,
+ROMAN_LOWER_OFFSET + ARABIC_OFFSET + ALPHA_LOWER_OFFSET + ROMAN_UPPER_OFFSET
+};
+static char page_prec[ARRAY_MAX] = PRECEDENCE_DEF;
+
+static int put_dot;
+
+static int count_lfd ARGS((char *str));
+static int next_nonblank ARGS((void));
+static int process_precedence ARGS((void));
+static int scan_char ARGS((char *c));
+static int scan_spec ARGS((char *spec));
+static int scan_string ARGS((char *str));
+
+void
+scan_sty(VOID_ARG)
+{
+ char spec[STRING_MAX];
+ int tmp;
+
+ MESSAGE("Scanning style file %s", sty_fn);
+ while (scan_spec(spec)) {
+ sty_tc++;
+ put_dot = TRUE;
+
+ /* output pre- and post-ambles */
+ if (STREQ(spec, PREAMBLE)) {
+ (void) scan_string(preamble);
+ prelen = count_lfd(preamble);
+ } else if (STREQ(spec, POSTAMBLE)) {
+ (void) scan_string(postamble);
+ postlen = count_lfd(postamble);
+ } else if (STREQ(spec, GROUP_SKIP)) {
+ (void) scan_string(group_skip);
+ skiplen = count_lfd(group_skip);
+ } else if (STREQ(spec, HEADINGS_FLAG)) {
+ SCAN_NO(&headings_flag);
+ } else if (STREQ(spec, HEADING_PRE)) {
+ (void) scan_string(heading_pre);
+ headprelen = count_lfd(heading_pre);
+ } else if (STREQ(spec, HEADING_SUF)) {
+ (void) scan_string(heading_suf);
+ headsuflen = count_lfd(heading_suf);
+ } else if (STREQ(spec, SYMHEAD_POS)) {
+ (void) scan_string(symhead_pos);
+ } else if (STREQ(spec, SYMHEAD_NEG)) {
+ (void) scan_string(symhead_neg);
+ } else if (STREQ(spec, NUMHEAD_POS)) {
+ (void) scan_string(numhead_pos);
+ } else if (STREQ(spec, NUMHEAD_NEG)) {
+ (void) scan_string(numhead_neg);
+ } else if (STREQ(spec, SETPAGEOPEN)) {
+ (void) scan_string(setpage_open);
+ setpagelen = count_lfd(setpage_open);
+ } else if (STREQ(spec, SETPAGECLOSE)) {
+ (void) scan_string(setpage_close);
+ setpagelen = count_lfd(setpage_close);
+ /* output index item commands */
+ } else if (STREQ(spec, ITEM_0)) {
+ (void) scan_string(item_r[0]);
+ ilen_r[0] = count_lfd(item_r[0]);
+ } else if (STREQ(spec, ITEM_1)) {
+ (void) scan_string(item_r[1]);
+ ilen_r[1] = count_lfd(item_r[1]);
+ } else if (STREQ(spec, ITEM_2)) {
+ (void) scan_string(item_r[2]);
+ ilen_r[2] = count_lfd(item_r[2]);
+ } else if (STREQ(spec, ITEM_01)) {
+ (void) scan_string(item_u[1]);
+ ilen_u[1] = count_lfd(item_u[1]);
+ } else if (STREQ(spec, ITEM_12)) {
+ (void) scan_string(item_u[2]);
+ ilen_u[2] = count_lfd(item_u[2]);
+ } else if (STREQ(spec, ITEM_x1)) {
+ (void) scan_string(item_x[1]);
+ ilen_x[1] = count_lfd(item_x[1]);
+ } else if (STREQ(spec, ITEM_x2)) {
+ (void) scan_string(item_x[2]);
+ ilen_x[2] = count_lfd(item_x[2]);
+ /* output encapsulators */
+ } else if (STREQ(spec, ENCAP_0))
+ (void) scan_string(encap_p);
+ else if (STREQ(spec, ENCAP_1))
+ (void) scan_string(encap_i);
+ else if (STREQ(spec, ENCAP_2))
+ (void) scan_string(encap_s);
+ /* output delimiters */
+ else if (STREQ(spec, DELIM_0))
+ (void) scan_string(delim_p[0]);
+ else if (STREQ(spec, DELIM_1))
+ (void) scan_string(delim_p[1]);
+ else if (STREQ(spec, DELIM_2))
+ (void) scan_string(delim_p[2]);
+ else if (STREQ(spec, DELIM_N))
+ (void) scan_string(delim_n);
+ else if (STREQ(spec, DELIM_R))
+ (void) scan_string(delim_r);
+ else if (STREQ(spec, DELIM_T))
+ (void) scan_string(delim_t);
+ else if (STREQ(spec, SUFFIX_2P))
+ (void) scan_string(suffix_2p);
+ else if (STREQ(spec, SUFFIX_3P))
+ (void) scan_string(suffix_3p);
+ else if (STREQ(spec, SUFFIX_MP))
+ (void) scan_string(suffix_mp);
+ /* output line width */
+ else if (STREQ(spec, LINEMAX)) {
+ SCAN_NO(&tmp);
+ if (tmp > 0)
+ linemax = tmp;
+ else
+ STY_ERROR2("%s must be positive (got %d)",
+ LINEMAX, tmp);
+ /* output line indentation length */
+ } else if (STREQ(spec, INDENT_LENGTH)) {
+ SCAN_NO(&tmp);
+ if (tmp >= 0)
+ indent_length = tmp;
+ else
+ STY_ERROR2("%s must be nonnegative (got %d)",
+ INDENT_LENGTH, tmp);
+ /* output line indentation */
+ } else if (STREQ(spec, INDENT_SPACE)) {
+ (void) scan_string(indent_space);
+ /* composite page delimiter */
+ } else if (STREQ(spec, COMPOSITOR)) {
+ (void) scan_string(page_comp);
+ /* page precedence */
+ } else if (STREQ(spec, PRECEDENCE)) {
+ (void) scan_string(page_prec);
+ (void) process_precedence();
+ /* index input format */
+ } else if (STREQ(spec, KEYWORD))
+ (void) scan_string(idx_keyword);
+ else if (STREQ(spec, AOPEN))
+ (void) scan_char(&idx_aopen);
+ else if (STREQ(spec, ACLOSE))
+ (void) scan_char(&idx_aclose);
+ else if (STREQ(spec, LEVEL))
+ (void) scan_char(&idx_level);
+ else if (STREQ(spec, ROPEN))
+ (void) scan_char(&idx_ropen);
+ else if (STREQ(spec, RCLOSE))
+ (void) scan_char(&idx_rclose);
+ else if (STREQ(spec, QUOTE))
+ (void) scan_char(&idx_quote);
+ else if (STREQ(spec, ACTUAL))
+ (void) scan_char(&idx_actual);
+ else if (STREQ(spec, ENCAP))
+ (void) scan_char(&idx_encap);
+ else if (STREQ(spec, ESCAPE))
+ (void) scan_char(&idx_escape);
+ else {
+ (void) next_nonblank();
+ STY_SKIPLINE;
+ STY_ERROR("Unknown specifier %s.\n", spec);
+ put_dot = FALSE;
+ }
+ if (put_dot) {
+ STY_DOT;
+ }
+ }
+
+ /* check if quote and escape are distinct */
+ if (idx_quote == idx_escape) {
+ STY_ERROR(
+ "Quote and escape symbols must be distinct (both `%c' now).\n",
+ idx_quote);
+ idx_quote = IDX_QUOTE;
+ idx_escape = IDX_ESCAPE;
+ }
+ DONE(sty_tc - sty_ec, "attributes redefined", sty_ec, "ignored");
+ CLOSE(sty_fp);
+}
+
+static int
+#if STDC
+scan_spec(char spec[])
+#else
+scan_spec(spec)
+char spec[];
+#endif
+{
+ int i = 0;
+ int c;
+
+ while (TRUE)
+ if ((c = next_nonblank()) == -1)
+ return (FALSE);
+ else if (c == COMMENT) {
+ STY_SKIPLINE;
+ } else
+ break;
+
+ spec[0] = TOLOWER(c);
+ while ((i++ < STRING_MAX) && ((c = GET_CHAR(sty_fp)) != SPC) &&
+ (c != TAB) && (c != LFD) && (c != EOF))
+ spec[i] = TOLOWER(c);
+ if (i < STRING_MAX) {
+ spec[i] = NUL;
+ if (c == EOF) {
+ STY_ERROR(
+ "No attribute for specifier %s (premature EOF)\n",
+ spec);
+ return (-1);
+ }
+ if (c == LFD)
+ sty_lc++;
+ return (TRUE);
+ } else {
+ STY_ERROR2("Specifier %s too long (max %d).\n",
+ spec, STRING_MAX);
+ return (FALSE);
+ }
+}
+
+
+static int
+next_nonblank(VOID_ARG)
+{
+ int c;
+
+ while (TRUE) {
+ switch (c = GET_CHAR(sty_fp)) {
+ case EOF:
+ return (-1);
+
+ case LFD:
+ sty_lc++;
+ case SPC:
+ case TAB:
+ break;
+ default:
+ return (c);
+ }
+ }
+#if IBM_PC_TURBO
+ return (-1); /* not reached, but keeps compiler happy */
+#endif
+}
+
+
+static int
+#if STDC
+scan_string(char str[])
+#else
+scan_string(str)
+char str[];
+#endif
+{
+ char clone[ARRAY_MAX];
+ int i = 0;
+ int c;
+
+ switch (c = next_nonblank()) {
+ case STR_DELIM:
+ while (TRUE)
+ switch (c = GET_CHAR(sty_fp)) {
+ case EOF:
+ STY_ERROR("No closing delimiter in %s.\n",
+ clone);
+ return (FALSE);
+ case STR_DELIM:
+ clone[i] = NUL;
+ strcpy(str, clone);
+ return (TRUE);
+ case BSH:
+ switch (c = GET_CHAR(sty_fp)) {
+ case 't':
+ clone[i++] = TAB;
+ break;
+ case 'n':
+ clone[i++] = LFD;
+ break;
+
+ default:
+ clone[i++] = (char) c;
+ break;
+ }
+ break;
+ default:
+ if (c == LFD)
+ sty_lc++;
+ if (i < ARRAY_MAX)
+ clone[i++] = (char) c;
+ else {
+ STY_SKIPLINE;
+ STY_ERROR2(
+ "Attribute string %s too long (max %d).\n",
+ clone, ARRAY_MAX);
+ return (FALSE);
+ }
+ break;
+ }
+ break;
+ case COMMENT:
+ STY_SKIPLINE;
+ break;
+ default:
+ STY_SKIPLINE;
+ STY_ERROR("No opening delimiter.\n", "");
+ return (FALSE);
+ }
+ return (TRUE); /* function value no longer used */
+}
+
+
+static int
+#if STDC
+scan_char(char *c)
+#else
+scan_char(c)
+char *c;
+#endif
+{
+ int clone;
+
+ switch (clone = next_nonblank()) {
+ case CHR_DELIM:
+ switch (clone = GET_CHAR(sty_fp)) {
+ case CHR_DELIM:
+ STY_SKIPLINE;
+ STY_ERROR("Premature closing delimiter.\n", "");
+ return (FALSE);
+ case LFD:
+ sty_lc++;
+ case EOF:
+ STY_ERROR("No character (premature EOF).\n", "");
+ return (FALSE);
+ case BSH:
+ clone = GET_CHAR(sty_fp);
+ default:
+ if (GET_CHAR(sty_fp) == CHR_DELIM) {
+ *c = (char) clone;
+ return (TRUE);
+ } else {
+ STY_ERROR("No closing delimiter or too many letters.\n", "");
+ return (FALSE);
+ }
+ }
+ /* break; */ /* NOT REACHED */
+ case COMMENT:
+ STY_SKIPLINE;
+ break;
+ default:
+ STY_SKIPLINE;
+ STY_ERROR("No opening delimiter.\n", "");
+ return (FALSE);
+ }
+ return (TRUE); /* function value no longer used */
+}
+
+
+static int
+#if STDC
+count_lfd(char *str)
+#else
+count_lfd(str)
+char *str;
+#endif
+{
+ int i = 0;
+ int n = 0;
+
+ while (str[i] != NUL) {
+ if (str[i] == LFD)
+ n++;
+ i++;
+ }
+ return (n);
+}
+
+
+static int
+process_precedence(VOID_ARG)
+{
+ int order[PAGETYPE_MAX];
+ int type[PAGETYPE_MAX];
+ int i = 0;
+ int last;
+ int roml = FALSE;
+ int romu = FALSE;
+ int arab = FALSE;
+ int alpl = FALSE;
+ int alpu = FALSE;
+
+ /* check for llegal specifiers first */
+ while ((i < PAGETYPE_MAX) && (page_prec[i] != NUL)) {
+ switch (page_prec[i]) {
+ case ROMAN_LOWER:
+ if (roml) {
+ MULTIPLE(ROMAN_LOWER);
+ } else
+ roml = TRUE;
+ break;
+ case ROMAN_UPPER:
+ if (romu) {
+ MULTIPLE(ROMAN_UPPER);
+ } else
+ romu = TRUE;
+ break;
+ case ARABIC:
+ if (arab) {
+ MULTIPLE(ARABIC);
+ } else
+ arab = TRUE;
+ break;
+ case ALPHA_LOWER:
+ if (alpl) {
+ MULTIPLE(ALPHA_UPPER);
+ } else
+ alpl = TRUE;
+ break;
+ case ALPHA_UPPER:
+ if (alpu) {
+ MULTIPLE(ALPHA_UPPER);
+ } else
+ alpu = TRUE;
+ break;
+ default:
+ STY_SKIPLINE;
+ STY_ERROR("Unknow type `%c' in page precedence specification.\n",
+ page_prec[i]);
+ return (FALSE);
+ }
+ i++;
+ }
+ if (page_prec[i] != NUL) {
+ STY_SKIPLINE;
+ STY_ERROR("Page precedence specification string too long.\n", "");
+ return (FALSE);
+ }
+ last = i;
+ switch (page_prec[0]) {
+ case ROMAN_LOWER:
+ order[0] = ROMAN_LOWER_OFFSET;
+ type[0] = ROML;
+ break;
+ case ROMAN_UPPER:
+ order[0] = ROMAN_UPPER_OFFSET;
+ type[0] = ROMU;
+ break;
+ case ARABIC:
+ order[0] = ARABIC_OFFSET;
+ type[0] = ARAB;
+ break;
+ case ALPHA_LOWER:
+ order[0] = ALPHA_LOWER_OFFSET;
+ type[0] = ALPL;
+ break;
+ case ALPHA_UPPER:
+ order[0] = ALPHA_LOWER_OFFSET;
+ type[0] = ALPU;
+ break;
+ }
+
+ i = 1;
+ while (i < last) {
+ switch (page_prec[i]) {
+ case ROMAN_LOWER:
+ order[i] = order[i - 1] + ROMAN_LOWER_OFFSET;
+ type[i] = ROML;
+ break;
+ case ROMAN_UPPER:
+ order[i] = order[i - 1] + ROMAN_UPPER_OFFSET;
+ type[i] = ROMU;
+ break;
+ case ARABIC:
+ order[i] = order[i - 1] + ARABIC_OFFSET;
+ type[i] = ARAB;
+ break;
+ case ALPHA_LOWER:
+ order[i] = order[i - 1] + ALPHA_LOWER_OFFSET;
+ type[i] = ALPL;
+ break;
+ case ALPHA_UPPER:
+ order[i] = order[i - 1] + ALPHA_LOWER_OFFSET;
+ type[i] = ALPU;
+ break;
+ }
+ i++;
+ }
+
+ for (i = 0; i < PAGETYPE_MAX; i++) {
+ page_offset[i] = -1;
+ }
+ page_offset[type[0]] = 0;
+ for (i = 1; i < last; i++) {
+ page_offset[type[i]] = order[i - 1];
+ }
+ for (i = 0; i < PAGETYPE_MAX; i++) {
+ if (page_offset[i] == -1) {
+ switch (type[last - 1]) {
+ case ROML:
+ order[last] = order[last - 1] + ROMAN_LOWER_OFFSET;
+ break;
+ case ROMU:
+ order[last] = order[last - 1] + ROMAN_UPPER_OFFSET;
+ break;
+ case ARAB:
+ order[last] = order[last - 1] + ARABIC_OFFSET;
+ break;
+ case ALPL:
+ order[last] = order[last - 1] + ALPHA_LOWER_OFFSET;
+ break;
+ case ALPU:
+ order[last] = order[last - 1] + ALPHA_UPPER_OFFSET;
+ break;
+ }
+ type[last] = i;
+ page_offset[i] = order[last];
+ last++;
+ }
+ }
+ return (TRUE); /* function value no longer used */
+}
diff --git a/indexing/makeindex/src/scanst.h b/indexing/makeindex/src/scanst.h
new file mode 100644
index 0000000000..b766ed4c99
--- /dev/null
+++ b/indexing/makeindex/src/scanst.h
@@ -0,0 +1,232 @@
+/*
+ *
+ * This file is part of
+ * MakeIndex - A formatter and format independent index processor
+ *
+ * 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
+ *
+ * Author:
+ * Pehong Chen
+ * Chen & Harrison International Systems, Inc.
+ * Palo Alto, California
+ * USA
+ * (phc@renoir.berkeley.edu or chen@orc.olivetti.com)
+ *
+ * Contributors:
+ * Please refer to the CONTRIB file that comes with this release
+ * for a list of people who have contributed to this and/or previous
+ * release(s) of MakeIndex.
+ *
+ * All rights reserved by the copyright holders. See the copyright
+ * notice distributed with this software for a complete description of
+ * the conditions under which it is made available.
+ *
+ */
+
+#define COMMENT '%'
+#define STR_DELIM '"'
+#define CHR_DELIM '\''
+
+#define KEYWORD "keyword"
+#define AOPEN "arg_open"
+#define ACLOSE "arg_close"
+#define ROPEN "range_open"
+#define RCLOSE "range_close"
+#define LEVEL "level"
+#define QUOTE "quote"
+#define ACTUAL "actual"
+#define ENCAP "encap"
+#define ESCAPE "escape"
+
+#define IDX_KEYWORD "\\indexentry"
+#define IDX_AOPEN '{'
+#define IDX_ACLOSE '}'
+#define IDX_ROPEN '('
+#define IDX_RCLOSE ')'
+#define IDX_LEVEL '!'
+#define IDX_QUOTE '"'
+#define IDX_ACTUAL '@'
+#define IDX_ENCAP '|'
+#define IDX_ESCAPE '\\'
+
+#define COMPOSITOR "page_compositor"
+#define COMPOSITOR_DEF "-"
+#define PRECEDENCE "page_precedence"
+#define PRECEDENCE_DEF "rnaRA"
+#define ROMAN_LOWER 'r'
+#define ROMAN_UPPER 'R'
+#define ARABIC 'n'
+#define ALPHA_LOWER 'a'
+#define ALPHA_UPPER 'A'
+#define ROMAN_LOWER_OFFSET 10000
+#define ROMAN_UPPER_OFFSET 10000
+#define ARABIC_OFFSET 10000
+#define ALPHA_LOWER_OFFSET 26
+#define ALPHA_UPPER_OFFSET 26
+
+#define PREAMBLE "preamble"
+#define PREAMBLE_DEF "\\begin{theindex}\n"
+#define PREAMBLE_LEN 1
+#define POSTAMBLE "postamble"
+#define POSTAMBLE_DEF "\n\n\\end{theindex}\n"
+#define POSTAMBLE_LEN 3
+
+#define SETPAGEOPEN "setpage_prefix"
+#define SETPAGECLOSE "setpage_suffix"
+
+#if KCC_20
+/* KCC preprocessor bug collapses multiple blanks to single blank */
+#define SETPAGEOPEN_DEF "\n\040\040\\setcounter{page}{"
+#else
+#define SETPAGEOPEN_DEF "\n \\setcounter{page}{"
+#endif /* KCC_20 */
+
+#define SETPAGECLOSE_DEF "}\n"
+#define SETPAGE_LEN 2
+
+#define GROUP_SKIP "group_skip"
+#if KCC_20
+/* KCC preprocessor bug collapses multiple blanks to single blank */
+#define GROUPSKIP_DEF "\n\n\040\040\\indexspace\n"
+#else
+#define GROUPSKIP_DEF "\n\n \\indexspace\n"
+#endif /* KCC_20 */
+#define GROUPSKIP_LEN 3
+
+#define HEADINGS_FLAG "headings_flag"
+#define HEADINGSFLAG_DEF 0
+#define HEADING_PRE "heading_prefix"
+#define HEADINGPRE_DEF ""
+#define HEADINGPRE_LEN 0
+#define HEADING_SUF "heading_suffix"
+#define HEADINGSUF_DEF ""
+#define HEADINGSUF_LEN 0
+#define SYMHEAD_POS "symhead_positive"
+#define SYMHEADPOS_DEF "Symbols"
+#define SYMHEAD_NEG "symhead_negative"
+#define SYMHEADNEG_DEF "symbols"
+#define NUMHEAD_POS "numhead_positive"
+#define NUMHEADPOS_DEF "Numbers"
+#define NUMHEAD_NEG "numhead_negative"
+#define NUMHEADNEG_DEF "numbers"
+
+#define ITEM_0 "item_0"
+#define ITEM_1 "item_1"
+#define ITEM_2 "item_2"
+#define ITEM_01 "item_01"
+#define ITEM_x1 "item_x1"
+#define ITEM_12 "item_12"
+#define ITEM_x2 "item_x2"
+
+#if KCC_20
+/* KCC preprocessor bug collapses multiple blanks to single blank */
+#define ITEM0_DEF "\n\040\040\\item\040"
+#define ITEM1_DEF "\n\040\040\040\040\\subitem\040"
+#define ITEM2_DEF "\n\040\040\040\040\040\040\\subsubitem\040"
+#else
+#define ITEM0_DEF "\n \\item "
+#define ITEM1_DEF "\n \\subitem "
+#define ITEM2_DEF "\n \\subsubitem "
+#endif /* KCC_20 */
+
+#define ITEM_LEN 1
+
+#define DELIM_0 "delim_0"
+#define DELIM_1 "delim_1"
+#define DELIM_2 "delim_2"
+#define DELIM_N "delim_n"
+#define DELIM_R "delim_r"
+#define DELIM_T "delim_t"
+#define DELIM_DEF ", "
+#define DELIMR_DEF "--"
+#define DELIMT_DEF ""
+
+#define SUFFIX_2P "suffix_2p"
+#define SUFFIX_3P "suffix_3p"
+#define SUFFIX_MP "suffix_mp"
+
+#define ENCAP_0 "encap_prefix"
+#define ENCAP_1 "encap_infix"
+#define ENCAP_2 "encap_suffix"
+#define ENCAP0_DEF "\\"
+#define ENCAP1_DEF "{"
+#define ENCAP2_DEF "}"
+
+#define LINEMAX "line_max"
+#define INDENT_SPACE "indent_space"
+#define INDENT_LENGTH "indent_length"
+
+#if (OS_BS2000 | OS_MVSXA)
+#define INDENTSPC_DEF " "
+#else
+#define INDENTSPC_DEF "\t\t"
+#endif /* OS_BS2000 | OS_MVSXA */
+
+#define INDENTLEN_DEF 16
+
+#define STY_ERROR(F, D) { \
+ if (idx_dot) { \
+ fprintf(ilg_fp, "\n"); \
+ idx_dot = FALSE; \
+ } \
+ fprintf(ilg_fp, "** Input style error (file = %s, line = %d):\n -- ", \
+ sty_fn, sty_lc); \
+ fprintf(ilg_fp, F, D); \
+ sty_ec++; \
+ put_dot = FALSE; \
+}
+
+#if KCC_20
+/* KCC preprocessor bug collapses multiple blanks to single blank */
+#define STY_ERROR2(F, D1, D2) { \
+ if (idx_dot) { \
+ fprintf(ilg_fp, "\n"); \
+ idx_dot = FALSE; \
+ } \
+ fprintf(ilg_fp, \
+ "** Input style error (file = %s, line = %d):\n\040\040 -- ", \
+ sty_fn, sty_lc); \
+ fprintf(ilg_fp, F, D1, D2); \
+ sty_ec++; \
+ put_dot = FALSE; \
+}
+#else
+#define STY_ERROR2(F, D1, D2) { \
+ if (idx_dot) { \
+ fprintf(ilg_fp, "\n"); \
+ idx_dot = FALSE; \
+ } \
+ fprintf(ilg_fp, "** Input style error (file = %s, line = %d):\n -- ", \
+ sty_fn, sty_lc); \
+ fprintf(ilg_fp, F, D1, D2); \
+ sty_ec++; \
+ put_dot = FALSE; \
+}
+#endif /* KCC_20 */
+
+#define STY_DOT { \
+ idx_dot = TRUE; \
+ if (verbose) \
+ fprintf(stderr, DOT); \
+ fprintf(ilg_fp, DOT); \
+}
+
+#define STY_SKIPLINE { \
+ int a; \
+ while ( ((a = GET_CHAR(sty_fp)) != LFD) && (a != EOF) ); \
+ sty_lc++; \
+}
+
+#define SCAN_NO(N) { \
+ fscanf(sty_fp, "%d", N); \
+}
+
+#define MULTIPLE(C) { \
+ STY_SKIPLINE; \
+STY_ERROR2( \
+"Multiple instances of type `%c' in page precedence specification `%s'.\n", \
+C, page_prec); \
+ return (FALSE); \
+}
diff --git a/indexing/makeindex/src/sortid.c b/indexing/makeindex/src/sortid.c
new file mode 100644
index 0000000000..d1ca0ac9fc
--- /dev/null
+++ b/indexing/makeindex/src/sortid.c
@@ -0,0 +1,360 @@
+/*
+ *
+ * This file is part of
+ * MakeIndex - A formatter and format independent index processor
+ *
+ * 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
+ *
+ * Author:
+ * Pehong Chen
+ * Chen & Harrison International Systems, Inc.
+ * Palo Alto, California
+ * USA
+ * (phc@renoir.berkeley.edu or chen@orc.olivetti.com)
+ *
+ * Contributors:
+ * Please refer to the CONTRIB file that comes with this release
+ * for a list of people who have contributed to this and/or previous
+ * release(s) of MakeIndex.
+ *
+ * All rights reserved by the copyright holders. See the copyright
+ * notice distributed with this software for a complete description of
+ * the conditions under which it is made available.
+ *
+ */
+
+#include "mkind.h"
+
+static long idx_gc;
+
+static int check_mixsym ARGS((char *x,char *y));
+static int compare ARGS((struct KFIELD * *a,struct KFIELD * *b));
+static int compare_one ARGS((char *x,char *y));
+static int compare_page ARGS((struct KFIELD * *a,struct KFIELD * *b));
+static int compare_string ARGS((unsigned char *a,unsigned char *b));
+static int new_strcmp ARGS((unsigned char *a, unsigned char *b,
+ int option));
+
+void
+sort_idx(VOID_ARG)
+{
+ MESSAGE("Sorting entries...", "");
+ idx_dc = 0;
+ idx_gc = 0L;
+ qqsort((char *) idx_key, (int) idx_gt, (int) sizeof(FIELD_PTR),
+ (int (*) ARGS((char*,char*)))compare);
+ MESSAGE("done (%ld comparisons).\n", idx_gc);
+}
+
+static int
+#if STDC
+compare(FIELD_PTR *a, FIELD_PTR *b)
+#else
+compare(a, b)
+FIELD_PTR *a;
+FIELD_PTR *b;
+#endif
+{
+ int i;
+ int dif;
+
+ idx_gc++;
+ IDX_DOT(CMP_MAX);
+
+ for (i = 0; i < FIELD_MAX; i++) {
+ /* compare the sort fields */
+ if ((dif = compare_one((*a)->sf[i], (*b)->sf[i])) != 0)
+ break;
+
+ /* compare the actual fields */
+ if ((dif = compare_one((*a)->af[i], (*b)->af[i])) != 0)
+ break;
+ }
+
+ /* both key aggregates are identical, compare page numbers */
+ if (i == FIELD_MAX)
+ dif = compare_page(a, b);
+ return (dif);
+}
+
+static int
+#if STDC
+compare_one(char *x,char *y)
+#else
+compare_one(x, y)
+char *x;
+char *y;
+#endif
+{
+ int m;
+ int n;
+
+ if ((x[0] == NUL) && (y[0] == NUL))
+ return (0);
+
+ if (x[0] == NUL)
+ return (-1);
+
+ if (y[0] == NUL)
+ return (1);
+
+ m = group_type(x);
+ n = group_type(y);
+
+ /* both pure digits */
+ if ((m >= 0) && (n >= 0))
+ return (m - n);
+
+ /* x digit, y non-digit */
+ if (m >= 0) {
+ if (german_sort)
+ return (1);
+ else
+ return ((n == -1) ? 1 : -1);
+ }
+ /* x non-digit, y digit */
+ if (n >= 0) {
+ if (german_sort)
+ return (-1);
+ else
+ return ((m == -1) ? -1 : 1);
+ }
+ /* strings started with a symbol (including digit) */
+ if ((m == SYMBOL) && (n == SYMBOL))
+ return (check_mixsym(x, y));
+
+ /* x symbol, y non-symbol */
+ if (m == SYMBOL)
+ return (-1);
+
+ /* x non-symbol, y symbol */
+ if (n == SYMBOL)
+ return (1);
+
+ /* strings with a leading letter, the ALPHA type */
+ return (compare_string((unsigned char*)x, (unsigned char*)y));
+}
+
+static int
+#if STDC
+check_mixsym(char *x, char *y)
+#else
+check_mixsym(x, y)
+char *x;
+char *y;
+#endif
+{
+ int m;
+ int n;
+
+ m = ISDIGIT(x[0]);
+ n = ISDIGIT(y[0]);
+
+ if (m && !n)
+ return (1);
+
+ if (!m && n)
+ return (-1);
+
+ return (strcmp(x, y));
+}
+
+
+static int
+#if STDC
+compare_string(unsigned char *a, unsigned char *b)
+#else
+compare_string(a, b)
+unsigned char *a;
+unsigned char *b;
+#endif
+{
+ int i = 0;
+ int j = 0;
+ int al;
+ int bl;
+
+ while ((a[i] != NUL) || (b[j] != NUL)) {
+ if (a[i] == NUL)
+ return (-1);
+ if (b[j] == NUL)
+ return (1);
+ if (letter_ordering) {
+ if (a[i] == SPC)
+ i++;
+ if (b[j] == SPC)
+ j++;
+ }
+ al = TOLOWER(a[i]);
+ bl = TOLOWER(b[j]);
+
+ if (al != bl)
+ return (al - bl);
+ i++;
+ j++;
+ }
+ if (german_sort)
+ return (new_strcmp(a, b, GERMAN));
+#if (OS_BS2000 | OS_MVSXA) /* in EBCDIC 'a' is lower than 'A' */
+ else
+ return (new_strcmp(a, b, ASCII));
+#else
+ else
+ return (strcmp((char*)a, (char*)b));
+#endif /* (OS_BS2000 | OS_MVSXA) */
+}
+
+static int
+#if STDC
+compare_page(FIELD_PTR *a, FIELD_PTR *b)
+#else
+compare_page(a, b)
+FIELD_PTR *a;
+FIELD_PTR *b;
+#endif
+{
+ int m = 0;
+ short i = 0;
+
+ while ((i < (*a)->count) && (i < (*b)->count) &&
+ ((m = (*a)->npg[i] - (*b)->npg[i]) == 0))
+ {
+ i++;
+ }
+ if (m == 0)
+ { /* common leading page numbers match */
+ if ((i == (*a)->count) && (i == (*b)->count))
+ { /* all page numbers match */
+#if 0 /* Faulty code replaced at 2.11 */
+ /* identical entries, except possibly in encap fields */
+ if (STREQ((*a)->encap, (*b)->encap))
+ { /* encap fields identical */
+ if (((*a)->type != DUPLICATE) &&
+ ((*b)->type != DUPLICATE))
+ (*b)->type = DUPLICATE;
+
+ else if ((*(*a)->encap == idx_ropen) ||
+ (*(*b)->encap == idx_rclose))
+ m = -1;
+ else if ((*(*a)->encap == idx_rclose) ||
+ (*(*b)->encap == idx_ropen))
+ m = 1;
+ }
+ else /* encap fields differ */
+ {
+ if ((*(*a)->encap == idx_ropen) &&
+ (*(*b)->encap == idx_rclose))
+ m = -1;
+ else if ((*(*a)->encap == idx_rclose) &&
+ (*(*b)->encap == idx_ropen))
+ m = 1;
+ /* else leave m == 0 */
+ }
+#else /* new 2.11 code */
+ /***********************************************************
+ We have identical entries, except possibly in encap fields.
+ The ordering is tricky here. Consider the following input
+ sequence of index names, encaps, and page numbers:
+
+ foo|( 2
+ foo|) 6
+ foo|( 6
+ foo|) 10
+
+ This might legimately occur when a page range ends, and
+ subsequently, a new range starts, on the same page. If we
+ just order by range_open and range_close (here, parens),
+ then we will produce
+
+ foo|( 2
+ foo|( 6
+ foo|) 6
+ foo|) 10
+
+ This will later generate the index entry
+
+ foo, 2--6, \({6}, 10
+
+ which is not only wrong, but has also introduced an illegal
+ LaTeX macro, \({6}, because the merging step treated this
+ like a \see{6} entry.
+
+ The solution is to preserve the original input order, which
+ we can do by treating range_open and range_close as equal,
+ and then ordering by input line number. This will then
+ generate the correct index entry
+
+ foo, 2--10
+
+ Ordering inconsistencies from missing range open or close
+ entries, or mixing roman and arabic page numbers, will be
+ detected later.
+ ***********************************************************/
+
+#define isrange(c) ( ((c) == idx_ropen) || ((c) == idx_rclose) )
+
+ /* Order two range values by input line number */
+
+ if (isrange(*(*a)->encap) && isrange(*(*b)->encap))
+ m = (*a)->lc - (*b)->lc;
+
+ /* Handle identical encap fields; neither is a range delimiter */
+
+ else if (STREQ((*a)->encap, (*b)->encap))
+ {
+ /* If neither are yet marked duplicate, mark the second
+ of them to be ignored. */
+ if (((*a)->type != DUPLICATE) &&
+ ((*b)->type != DUPLICATE))
+ (*b)->type = DUPLICATE;
+ /* leave m == 0 to show equality */
+ }
+
+ /* Encap fields differ: only one may be a range delimiter, */
+ /* or else neither of them is. If either of them is a range */
+ /* delimiter, order by input line number; otherwise, order */
+ /* by name. */
+
+ else
+ {
+ if ( isrange(*(*a)->encap) || isrange(*(*b)->encap) )
+ m = (*a)->lc - (*b)->lc; /* order by input line number */
+ else /* order non-range items by */
+ /* their encap strings */
+ m = compare_string((unsigned char*)((*a)->encap),
+ (unsigned char*)((*b)->encap));
+ }
+#endif
+ }
+ else if ((i == (*a)->count) && (i < (*b)->count))
+ m = -1;
+ else if ((i < (*a)->count) && (i == (*b)->count))
+ m = 1;
+ }
+ return (m);
+}
+
+
+static int
+#if STDC
+new_strcmp(unsigned char *s1, unsigned char *s2, int option)
+#else
+new_strcmp(s1, s2, option)
+unsigned char *s1;
+unsigned char *s2;
+int option;
+#endif
+{
+ int i;
+
+ i = 0;
+ while (s1[i] == s2[i])
+ if (s1[i++] == NUL)
+ return (0);
+ if (option) /* ASCII */
+ return (isupper(s1[i]) ? -1 : 1);
+ else /* GERMAN */
+ return (isupper(s1[i]) ? 1 : -1);
+}