summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/cweb-latex/examples/rcs.sty
blob: e3cfaec72ec2cb5533ceee6718b42609c50d6499 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
% This is a stripped version of rcs.sty,
% all comment lines and empty lines were discarded to save space. YOU
% ARE NOT ALLOWED to use this file for your own work. You may ONLY
% redistribute it as part of the complete distribution you received it.
% This file was created at Thu Nov 30 15:51:58 UTC 1995.

% The original file may be retrieved
% from CTAN, directory macros/tex/latex/contrib/supported/rcs/..

% ======================================================================

\ifx \rcs@loaded\undefined
    \def\rcs@loaded{$StyleRevision: 2.9 $}
\else
    \PackageWarningNoLine{rcs}%
	{Some other package already uses namespace `rcs'}
\fi
\begingroup
    \def\RCSPackage#1#2 $#3: #4 #5\endRCS $#6: #7 #8\endRCS{%
	\def\date{#4}\def\id{v#7}%
	\ProvidesPackage{#1}[\date\space\id\space #2]%
	}
  \RCSPackage{rcs}{typeset info from RCS fields}
  $StyleDate: 1995/08/02 12:09:07 $: 9999/00/00 \endRCS
  $StyleRevision: 2.9 $: 0.0 \endRCS
\endgroup
\ifx \CatEscape\undefined
    \chardef\CatEscape=0
    \chardef\CatOpen=1
    \chardef\CatClose=2
    \chardef\CatIgnore=9
    \chardef\CatLetter=11
    \chardef\CatOther=12
    \chardef\CatActive=13
    \chardef\CatUsCode=\catcode`\_
\fi
\catcode`\_=\CatLetter                  % top level macro file
\def\RcsEmptyValue{}
\def\rcs_split_field #1: #2 :#3\end_value{%
    \def\RCS_keyword{#1}%
    \def\RCS_value{#2}%
    \ifx \RCS_value\empty
	\let\RCS_value\RcsEmptyValue
    \fi
    }
\def\RCS $#1${%
    \rcs_split_field #1: {} :\end_value
    \expandafter\let \csname RCS\rcs_raw_if_handle\RCS_keyword\endcsname
		     \RCS_value
    \csname RcsHandle\RCS_keyword\endcsname
    }
\def\rcs_raw_if_handle{%
    \@ifundefined{RcsHandle\RCS_keyword}{}{Raw}%
    }
\def\RcsHandleDate{%
    \ifx \today\undefined
	\expandafter\let \csname RCS\RCS_keyword\endcsname \RCS_value
    \else
	\ifx \RCS_value\RcsEmptyValue
	    \@namedef{RCS\RCS_keyword}{\today}%
	    \let\RCSTime\empty
	\else
	    \expandafter\rcs_set_date \RCS_value\end_date
	\fi
    \fi
    }
\def\rcs_set_date #1/#2/#3 #4\end_date{%
    \begingroup
	\day #3			% <-- space!
	\month #2		% <-- space!
	\year #1		% <-- space!
	\expandafter\xdef \csname RCS\RCS_keyword\endcsname {\today}%
    \endgroup
    \def\RCSTime{#4}%
    }
\newtoks\rcsLogIntro
	\rcsLogIntro={}
\def\rcsAuthor#1#2{\@namedef{rcs_author:#1}{#2}}
\def\RCS_get_author#1{%
    \@ifundefined{rcs_author:#1}{#1}{\@nameuse{rcs_author:#1}}%
    }
\def\RcsLogStyle{%
    \def\RcsLogHeading{\subsubsection*}%
    \footnotesize
    }
\def\rcs_log_hdr#1,v\end_value{%
    \@rcs_empty_log@false
    \RcsLogHeading{\RcsLogHeadingName #1}%
    \the\rcsLogIntro
    }
\def\rcs_empty_log_value{%
    \global\@rcs_empty_log@true		% that's most probably in a group!
    \RcsUnknownFile			% text for unknown file name
    ,v%					% assert calling env
    }
\newif\if@rcs_empty_log@
\def\RcsLogHeadingName{Revision Log for \tt} % file name in monospace
\def\RcsUnknownFile{\rm $\langle\,$Unknown file name$\,\rangle$}
\def\RcsEmptyLog{{\itshape No log entries available.}}
\def\RcsLogRevision#1#2#3#4{%
    \item [Revision #1]%
      (created at \RcsLogDate #2\endDate\space \RcsLogTime{#3} % <-- space!
      by \RCS_get_author{#4})\\\relax
    }
\def\RcsLogDate #1/#2/#3\endDate{%
    \begingroup
	\day #3			% <-- space!
	\month #2		% <-- space!
	\year #1		% <-- space!
	\today
    \endgroup
    }
\def\RcsLogTime#1{\ignorespaces}
\def\rcs_settime{%
    \def\RcsLogTime##1{[##1]}%
    }
\def\rcslog{%
    \@ifnextchar[%			% ] (Emacs)
	\rcslog_configure
	{\rcslog_configure[]}%
    }
\def\rcslog_configure[#1]{%
    \let\Revision\rcslog_revision
    \let\settime\rcs_settime
    \RcsLogStyle
    #1%
    \afterassignment\rcslog_skipcr
    \let\next
    }
\def\rcslog_skipcr{%
    \ifx \next $%
	\def\next{\rcslog_field $}%
    \else\ifx \next\par
	\let\next\rcslog_field
    \else
	\PackageError{rcs}{Missing RCS Log field in environment}{%
The RCS Log field must be the very first text in the rcslog\MessageBreak
environment. I will discard the rest of your input line and try to\MessageBreak
recover then. If you think this won't work, exit now.\MessageBreak
Otherwise press <Return> and cross your fingers!}
	\let\next\rcslog_discard_line
    \fi\fi
    \next
    }
\def\rcslog_discard_line{%
    \begingroup
	\obeylines
	\rcslog_gobble_line
    }
\begingroup
\obeylines
\gdef\rcslog_gobble_line #1^^M{%
    \endgroup%
    \afterassignment\rcslog_skipcr%
    \let\next%
    }
\endgroup
\def\rcslog_field{%
    \begingroup
	\obeylines
	\rcslog_get_field
    }
\begingroup
\obeylines
\gdef\rcslog_get_field #1^^M{%
    \endgroup%
    \rcslog_set_field{#1}%
    }
\endgroup
\def\rcslog_set_field#1{%
    \let\RcsEmptyValue\rcs_empty_log_value
    \RCS #1%
    \expandafter\rcs_log_hdr \RCS_value\end_value
    \list{}\RcsLogListStyle		% empty label, layout configurable
    \if@rcs_empty_log@
	\item []\RcsEmptyLog		% supply missing item
    \fi
    }
\def\RcsLogListStyle{%
    \global\@listdepth\z@
    \labelwidth\z@		    % item label w/o fixed size
    \itemindent -\leftmargin	    % move label before start of line
    \advance\itemindent \labelsep   % label was moved too much
    \def\makelabel##1{\bf ##1}%	    % how to typeset labels
    \parsep\z@skip		    % no space between pars in items
    \listparindent 1em		    % <-- space!  indent pars in items
    }%
\let\endrcslog\endtrivlist
\def\rcslog_revision{%
    \begingroup
	\obeylines
	\rcslog_get_revinfo
    }
\begingroup
\obeylines
\gdef\rcslog_get_revinfo #1 #2 #3 #4^^M{%
    \endgroup%
    \RcsLogRevision{#1}{#2}{#3}{#4}%
    }
\endgroup
\def\RCSdate $#1${%
    \RCS $#1$%
    \expandafter\date \expandafter{\csname RCS\RCS_keyword\endcsname}%
    }
\def\RCSID{%
    \@ifnextchar\bgroup
	\rcsid_get_field
	\rcs_id
    }
\def\rcsid_get_field#1{\rcs_id #1}
\def\rcs_id $#1${%
    \RCS $#1$%
    \begingroup
	\let\protect\noexpand
	\xdef\@oddfoot{%
	    \reset@font
	    \protect\framebox[\textwidth]{\RCS_keyword: \RCS_value}%
	    }%
    \endgroup
    \global\let\@evenfoot\@oddfoot
    }
\def\RCSdef $#1${%
    \typeout{RCS field: $#1$}%
    \RCS $#1$%
    }
\catcode`\_=\CatUsCode
\endinput