summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/kuvio/doc-src/macros/carrot/basic/contents.cd
blob: 13e158bf7aaca748607f4c96e275ed6cb542987d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
%  contents.cd
%  Anders G S Svensson

%  Source:  contents.nw
%           $Revision: 1.13 $
%           $Date: 1996/02/23 03:03:12 $

\usecarrot{auxfile}

\newauxfile{ccx}

\def\readccx{%
   \IfFileExists{\jobname.ccx}%
      {\expandafter\contents@open@\contents@list@{}%
       {\@makeatletter@ \input\jobname.ccx\relax}%
       \expandafter\contents@close@\contents@list@{}}
      {}%
   \global\let\readccx\relax}

\def\newcontentsfile{\bgroup\@ignorewhitespace@\contents@newfile@}
\def\contents@newfile@#1{\egroup
   \xdef\contents@list@{\contents@list@{#1}}%
   \@let@{#1contents}\relax
   \@let@{end#1contents}\relax
   \@csafter@\auxfile@newwrite@{contents@toc@#1}}
\let\contents@list@\@empty@

\def\contents@open@#1{%
   \@ifempty@{#1}%
      {}%
      {\immediate\openout\@cs@{contents@toc@#1}=\jobname.#1\relax
       \contents@writefile@{#1}{%
          \expandafter\noexpand\csname #1contents\endcsname}%
       \contents@open@}}
\def\contents@close@#1{%
   \@ifempty@{#1}%
      {}%
      {\contents@writefile@{#1}{%
          \expandafter\noexpand\csname end#1contents\endcsname}%
       \immediate\closeout\@cs@{contents@toc@#1}\relax\contents@close@}}

\def\contents@writefile@#1{%
   \immediate\write\@cs@{contents@toc@#1}}

\def\contents@writetoks@#1#2{%
   \def\@tmp@{#2}\contents@writefile@{#1}{\@meaning@\@tmp@}}

\def\readcontentsfile#1{\relax
   \readccx
   \@ifundefined@{contents@toc@#1}%
      {\@Warning@{Undeclared contents file: #1}}%
      {\InputIfFileExists{\jobname.#1\relax}}}
\def\writecontentsfile#1#2{\relax
   \@ifundefined@{contents@toc@#1}%
      {\@Warning@{Undeclared contents file: #1}}%
      {\def\@tmp@{\contents@writetoks@{#1}{#2}}%
       \edef\@action@{\noexpand\writeccx{\@meaning@\@tmp@}}%
       \@action@}}
\def\writecontentsentry{\relax
   \@ifnextchar@*%
      {\expandafter\contents@writeentry@\expandafter\contents@sentry@\@eat@}%
      {\contents@writeentry@\contents@entry@}}

\def\contents@writeentry@#1#2{%
   \@ifundefined@{contents@toc@#2}%
      {\@Warning@{Undeclared contents file: #2}}%
      {\readccx \openccx #1{#2}}}

\def\contents@sentry@#1#2#3{%
   \def\@tmp@{\contents@swrite@{#1}{#2}{#3}}%
   \edef\@action@{%
      \noexpand\writeccx{\@meaning@\@tmp@{\noexpand\folio}}}%
   \@action@}

\def\contents@entry@#1#2#3#4{%
   \def\@tmp@{\contents@write@{#1}{#2}{#3}}%
   \edef\@action@{%
      \noexpand\writeccx{\@meaning@\@tmp@{#4}{\noexpand\folio}}}%
   \@action@}
\def\contents@swrite@#1#2#3#4{%
   \def\@tmp@{{#3}{#4}}%
   \contents@writefile@{#1}{%
      \expandafter\noexpand\csname #1#2entryu\endcsname\@meaning@\@tmp@}}

\def\contents@write@#1#2#3#4#5{%
   \def\@tmp@{{#3}{#4}{#5}}%
   \contents@writefile@{#1}{%
      \expandafter\noexpand\csname #1#2entry\endcsname\@meaning@\@tmp@}}