Debian Codegraph @

texmf-dist/tex/generic/tex4ht/idxmake.4ht

raw
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 % idxmake.4ht 2009-05-21-09:32 %
3 % Copyright (C) 2000--2009 Eitan M. Gurari %
4 % %
5 % This work may be distributed and/or modified under the %
6 % conditions of the LaTeX Project Public License, either %
7 % version 1.3c of this license or (at your option) any %
8 % later version. The latest version of this license is %
9 % in %
10 % http://www.latex-project.org/lppl.txt %
11 % and version 1.3c or later is part of all distributions %
12 % of LaTeX version 2005/12/01 or later. %
13 % %
14 % This work has the LPPL maintenance status "maintained".%
15 % %
16 % This Current Maintainer of this work %
17 % is Eitan M. Gurari. %
18 % %
19 % If you modify this program your changing its signature %
20 % with a directive of the following form will be %
21 % appreciated. %
22 % \message{signature} %
23 % %
24 % [email protected] %
25 % http://www.cse.ohio-state.edu/~gurari %
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 \immediate\write-1{version 2009-05-21-09:32}
28
29
30 \def\SourceInd#1#2#3#4{#1.#2}
31 \def\MakefileInd#1#2#3#4{#1.#4}
32
33 \newcount\cnt
34 \newtoks\split
35
36 \def\noXcatcodes{%
37 \cnt=0
38 \def\noXXcatcodes{%
39 \catcode\cnt12
40 \ifnum\cnt<255
41 \advance\cnt 1 \expandafter\noXXcatcodes
42 \fi }%
43 \noXXcatcodes }
44
45 \newwrite\idx
46 \newwrite\indexes
47 \def\MakefileIn#1#2#3#4{#1.#3}
48 \def\MakefileIndexes#1#2#3#4{#1.4ix}
49 \immediate\openout\idx=\expandafter\MakefileIn\filename\relax
50 \immediate\openout\indexes=\expandafter\MakefileIndexes\filename\relax
51
52 \def\beforeentry#1#2#3#4{
53 \def\file{#1}\def\anchor{#2}\def\pointer{#3}\def\indexentry{\string#4}
54 \begingroup \noXcatcodes
55 \catcode`\s=11 \catcode`\e=11 `%for \see`%
56 \catcode`\^^M=10 \catcode`\ =10 \catcode`\^^I=10
57 \catcode`\{=1 \catcode`\}=2 \futurelet\next\preGetentries
58 }
59 \def\bparent#1|(#2!*?: {\def\core{#1}\def\parent{#2}}
60 \def\eparent#1|)#2!*?: {\def\core{#1}\def\parent{#2}}
61 \def\see#1|see#2|see#3!*?: {\def\preSee{#1}\def\isSee{#2}}
62 \newcount\entryNum
63 \def\preGetentries{\ifx [\next \expandafter\opGetentries
64 \else \global\split={}\expandafter\getentries\fi}
65 \def\opGetentries[#1]{\global\split={[#1]}\getentries}
66
67 \def\getentries#1#2{\endgroup
68 \advance\entryNum by 1
69 \let\parent=\empty
70 \bparent#1|(!*?: \ifx \parent\empty
71 \eparent#1|)!*?: \ifx \parent\empty
72 \see#1|see|see!*?: %
73 \ifx \isSee\empty
74 \hasBar#1|!*?: {#1}{#2}%
75 \else
76 \immediate\write\idx{\indexentry\the\split{%
77 \preSee|see{\string\LNK{\file}{\anchor}{\isSee}{}}}{\the\entryNum
78 }}%
79 \immediate\write\indexes{\string \indexmark\the\split{%
80 \preSee}{\the\entryNum
81 }}%
82 \fi
83 %
84 \else
85 \immediate\write\idx{\indexentry\the\split{%
86 \core|LNK\csname \core|(\endcsname
87 --\string\LNK{\file}{\anchor}{\pointer}}{\the\entryNum
88 }}%
89 \immediate\write\indexes{\string \indexmark\the\split{%
90 \core}{\the\entryNum
91 }}%
92 \fi
93 \else
94 \expandafter\edef\csname \core|(\endcsname
95 {{\file}{\anchor}{\pointer}{\the\entryNum
96 }}%
97 \fi
98 }
99 \def\hasBar#1|#2!*?: #3#4{%
100 \def\temp{#2}\ifx \temp\empty
101 \immediate\write\idx{\indexentry\the\split{%
102 #3|LNK{\file}{\anchor}{\pointer}}{\the\entryNum
103 }}%
104 \immediate\write\indexes{\string \indexmark\the\split{%
105 #3}{\the\entryNum
106 }}%
107 \else \yeshasBar#3!*?: {\the\entryNum
108 }\fi
109 }
110 \def\yeshasBar#1|#2!*?: #3{%
111 \immediate\write\idx{\indexentry\the\split{%
112 #1|yhbLNK{#2}{\file}{\anchor}{\pointer}}{\the\entryNum
113 }}%
114 \immediate\write\indexes{\string \indexmark\the\split{%
115 #2}{\the\entryNum
116 }}%
117 }
118
119 \newcount\GetentriesN
120 \GetentriesN=0
121 \def\indexentry{\string\indexentry}
122 \def\Ganchor{\ifnum \GetentriesN<10 0\fi
123 \ifnum \GetentriesN<100 0\fi
124 \ifnum \GetentriesN<1000 0\fi
125 \the\GetentriesN}
126 \def\Beforeentry{\let\getentries=\Getentries
127 \let\Beforeentry=\beforeentry \Beforeentry}
128 \def\Getentries#1#2{\endgroup
129 \advance\GetentriesN by 1
130 \let\parent=\empty
131 \bparent#1|(!*?: \ifx \parent\empty
132 \eparent#1|)!*?: \ifx \parent\empty
133 \see#1|see|see!*?: %
134 \ifx \isSee\empty \immediate\write\idx{\indexentry\the\split{%
135 \string\indNum{\Ganchor}%
136 %
137 #1\string\indNum{\Ganchor}%
138 \string\comNum}{#2}}%
139 %
140 \else \immediate\write\idx{\indexentry\the\split{%
141 {\Ganchor}%
142 \preSee\string\gobble|see{\isSee}}{#2}}%
143 \fi
144 \else
145 \immediate\write\idx{\indexentry\the\split{%
146 \string\indNum{\Ganchor}%
147 \string\erange{\csname \core|(\endcsname}
148 \core\string\indNum{\Ganchor}%
149 \string\comNum}{#2}}%
150 \fi
151 \else
152 \immediate\write\idx{\indexentry\the\split{%
153 \string\indNum{\Ganchor}%
154 \string\brange{\Ganchor}
155 \core\string\indNum{\Ganchor}%
156 \string\comNum}{#2}}%
157 \expandafter\edef\csname \core|(\endcsname{\Ganchor}%
158 \fi
159 }
160
161 \input \expandafter\SourceInd\filename\relax
162 \immediate\closeout\idx
163 \immediate\closeout\indexes
164
165
166 \bye
167 \endinput
168