summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/svn-prov/svn-prov.dtx
blob: ff0066fab4e1e39edec4e7a14f5e6126d540febb (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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
% \iffalse meta-comment
% $Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $
%
% Copyright (C) 2009-2010 by Martin Scharrer <martin@scharrer-online.de>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%
%   http://www.latex-project.org/lppl.txt
%
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008/05/04 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Martin Scharrer.
%
% This work consists of the files svn-prov.dtx, svn-prov.ins
% and the derived file svn-prov.sty.
%
% \fi
%
% \iffalse
%<*driver>
\RequirePackage{svn-prov}
%</driver>
%<*driver|package>
\def\svnprov@version{v3.\rev}
%</driver|package>
%<*driver>
\ProvidesFileSVN{$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
  [\svnprov@version\space DTX for \filebase.sty]
\DefineFileInfoSVN
\GetFileInfoSVN*
% Re-require package to check date
\RequirePackage{svn-prov}[\filedate]

\documentclass{article}
\usepackage{ydoc}
\usepackage[hyperfootnotes=false]{hyperref}
\usepackage{booktabs}

\makeatletter
%%% Examples %%%
\RequirePackage{fancyvrb}
\RequirePackage{listings}

\renewenvironment{example}
  {\begingroup\VerbatimOut[gobble=4]{\jobname.exa}}
  {\endVerbatimOut\endgroup\formatexample}

\usepackage{ifthen,calc}

\def\examplebeforetext{The following code:}
\def\exampleaftertext{is equivalent to:}

\def\formatexample{%
  \par\noindent\examplebeforetext
  \lstinputlisting{\jobname.exa}\medskip
  \exampleaftertext\\[\medskipamount]%
  {\catcode`\%=14%
  \input{\jobname.exa}}%
  \par\bigskip
}

\lstset{%
  %numbers=left,
  numberstyle=\scriptsize\sffamily,
  basicstyle=\ttfamily,
  stepnumber=1,
  language=[latex]tex,
}%


\usepackage{xspace}
\let\pkg\relax
\newcommand*{\pkg}[1]{%
  \href{http://tug.ctan.org/pkg/#1}{\texttt{#1}}%
  % URL footnote (for print-out) on first appearance:
  \@ifundefined{seen@package@#1}{%
    \footnote{CTAN: \url{http://tug.ctan.org/pkg/#1}}%
    \@namedef{seen@package@#1}{1}%
  }{}%
  \xspace
}

\def\darg#1{\texttt{\frenchspacing\char`\{\$#1\$\char`\}}}

\makeatother

\EnableCrossrefs
\CodelineIndex
\RecordChanges

\let\manualnewpage\newpage
\listfiles
\begin{document}
  \DocInput{svn-prov.dtx}
  \PrintChanges
  \manualnewpage
  \PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{423}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v0.922}{2009/04/26}{Initial version}
% \changes{v1.}{2009/05/03}{Added \cs{DefineFileInfoSVN} macro.}
% \changes{v2.}{2010/03/25}{Fixed issues when used in font definition \texttt{*.fd} files due to changed catcodes.
% Also fixed error which occurred when Id line was not expanded.}
%
% ^^A \GetFileInfo{\jobname.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment,\def,\edef,\gdef,\xdef,\let,\@tempa}
% \DoNotIndex{\g@tempa,\textbackslash,\ifx,\if,\ifnum,\else,\fi,\relax,\space}
% \DoNotIndex{\@ifnextchar,\@gobble,\@undefined,\begingroup,\endgroup,\empty}
% \DoNotIndex{\expandafter,\NeedsTeXFormat}
%
% \title{The \textsf{svn-prov} package\\\large Use SVN Id keywords for package, 
% class and file header}
% \author{Martin Scharrer \\ \url{martin@scharrer-online.de}}
% \GetFileInfoSVN{svnprov}
% \date{Version~\fileversion\ - \filetoday}
%
% \maketitle
%
% \section{Introduction}
% This package is directed to authors of \LaTeX\ packages and classes which use 
% the version control software 
% \href{http://subversion.tigris.org/}{Subversion}\footnote
% {WWW: \url{http://subversion.tigris.org/}} (SVN) for their source files. It 
% introduces three macros which are Subversion variants of the standard \LaTeX\ 
% header macros \cs{ProvidesPackage}, \cs{ProvidesClass} and \cs{ProvidesFile} 
% which are used to identify package, class and other files, respectively.  
% Instead of providing the package/class/file name and date manually they are 
% extracted from a Subversion Id keywords string which
% is updated automatically by every time the source file is committed to the 
% repository.
% 
% A similar package exists for RCS, the pre-predecessor of Subversion, in the 
% \pkg{pgf} bundle which is called \texttt{pgfrcs}.
% For further support for Subversion keywords see the author's other package 
% \pkg{svn-multi}.
%
% \section{Usage}
% ^^A\subsection{Subversion Id Keyword}
% The following macros need an Id keyword which can initially be written as 
% `|$||Id:$|' and will be expanded by Subversion into the following format at 
% the next commit:\par\smallskip
% \texttt{\frenchspacing\${}Id: \meta{filename} \meta{revision} \meta{date} 
% \meta{time} \meta{author} \$}
% \par\smallskip
% \noindent e.g. for the source file of this document:\par\smallskip
% |$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $|
% \par\smallskip
% \noindent For this to work the Subversion \emph{property} \texttt{svn:keywords} must be 
% set to (at least) `|Id|' for the source file(s). e.g.\ using the command 
% line:\par\smallskip
% \texttt{svn propset 'svn:keyword' 'Id' \meta{filename(s)}}
% \par\smallskip\noindent
% \nopagebreak[3]\unskip
% More information about using Subversion in the \LaTeX\ workflow can be found in the 
% Prac\TeX{} Journal issue 2007-3\footnote
% {URL: 
% \ttfamily\url{http://www.tug.org/pracjourn/2007-3/}\char`\{\href
% {http://www.tug.org/pracjourn/2007-3/skiadas-svn}{skiadas-svn}\char`\|\href
% {http://www.tug.org/pracjourn/2007-3/ziegenhagen}{ziegenhagen}\char`\|\href
% {http://www.tug.org/pracjourn/2007-3/scharrer}{scharrer}\char`\}}.
%
% ^^A\subsection{Main Macros}
% \manualnewpage%%
% \DescribeMacro\ProvidesPackageSVN [<file name>] {\$Id:~\$} [<\small version and/or description>] [<\small description>]
% \DescribeMacro\ProvidesClassSVN   [<file name>] {\$Id:~\$} [<\small version and/or description>] [<\small description>]
% \DescribeMacro\ProvidesFileSVN    [<file name>] {\$Id:~\$} [<\small version and/or description>] [<\small description>]
%
% All of these macros await a valid Subversion Id keyword string as a mandatory 
% argument. The file name and date is extracted from this string. For cases when 
% the file source is not stored in the correct file but packed inside a 
% different one, like a |.dtx| file, the correct file name can be provided by an 
% optional argument. Because the file extension of package and class files is 
% predefined and therefore ignored this is not needed for them when they are 
% packed inside a corresponding |.dtx| file, i.e. one with the same base name.  
%
% As with the standard macros mentioned above additional information can be given optionally.
% Since v0.3 the SVN macro provide two optional arguments (before only one). 
% If only one optional argument is given it is taken as a description text which may start 
% with an potential version number. This version number must start with `|v|' and not include spaces
% and is extracted from the description. 
% Alternatively the version number and the description can be provided using two separate optional arguments.
% If no optional argument is given the default string \cs{revinfo} (see below) is used instead.
%
% All three optional arguments can include the following macros which are only valid
% inside them, but not afterwards\footnote{They can be set using \cs{GetFileInfoSVN}}:
% \begin{description}
%   \item[\cs{rev}] File revision.
%   \item[\cs{Rev}] File revision followed by a space.
%   \item[\cs{revinfo}] The default information used: 
%   ``\texttt{\frenchspacing(SVN Rev: \meta{revision})}''.
%   \item[\cs{filebase}] File base name (file name without extension).
%   \item[\cs{fileext}] File extension (without leading dot).
%   \item[\cs{filename}] File name.
%   \item[\cs{filedate}] File date (in the format YYYY/MM/DD).
%   \item[\cs{filerev}] File revision, like \cs{rev}.
% \end{description}
%
% ^^A\subsection{Other Macros}
% \par\medskip
% \DescribeMacro\GetFileInfoSVN{<name>}
% \DescribeMacro\GetFileInfoSVN*
% This macro\marginpar{\it\raggedright Non-star version added in v3. 2010/04/11}
% sets the macros \cs{filebase}, \cs{fileext}, \cs{filename}, \cs{filedate}, \cs{fileversion}, \cs{filerev},
% \cs{fileinfo} and \cs{filetoday} to the corresponding values of the file given by \meta{name}. The file must have been
% read/loaded before and use both a \cs{Provides\ldots SVN} macro and \cs{DefineFileInfoSVN}, otherwise the above macros
% will be set to |\relax|.  The \meta{name} can be either the real filename or the optional short name used with
% \cs{DefineFileInfoSVN}.
%
% The star version of this macro provides the file information of the last file which called one of the
% \cs{Provides\ldots SVN} macros.
%
% The macros \cs{fileversion} and \cs{fileinfo} hold the file version and description taken from optional argument of
% the \cs{Provide...SVN} macro.  The version is defined only if this argument starts with `|v|' and is otherwise empty.
% It includes all text up to the first space.
% The \cs{filetoday} macro generates a text representation of the \cs{filedate} using the \cs{today} macro. The format can be
% adjusted to a different language with the |\date|\meta{language} macro from the \pkg{babel} package.
% The other macros are described above.
%
%
% \par\medskip
% \DescribeMacro\DefineFileInfoSVN[<name>]
% Defined\marginpar{\it\raggedright New in v1. 2009/05/03}
% a set of macros which provide the information collected by a previous 
% \cs{Provides\ldots} macro. The macros have the form 
% |\|\meta{name}|@|\meta{data} where \meta{name} is by default the filename 
% either with the file extension (general files) or without (packages and 
% classes). This default can be overwritten by the optional argument.
% The \meta{data} stands for |version|, |rev| (revision), |date| and |info|
% (the information part without the version number)
% and, since v3,\marginpar{\it\raggedright Updated in v3. 2010/04/24}
% file name |base| and |ext|(ension) as well as |today|, which prints
% the |date| in the format of \cs{today}.
%
% \noindent
% \textit{Example:} Applied to the |.dtx| file of this very package the 
% following macros are defined:\par\medskip
% \begingroup
% \makeatletter\centering
% \begin{tabular}{ll}
%  \toprule
%  Macro  & Definition \\
%  \midrule
%  \cs{svn-prov.dtx@version} & \@nameuse{svn-prov.dtx@version} \\
%  \cs{svn-prov.dtx@rev}     & \@nameuse{svn-prov.dtx@rev}     \\
%  \cs{svn-prov.dtx@date}    & \@nameuse{svn-prov.dtx@date}    \\
%  \cs{svn-prov.dtx@info}    & \@nameuse{svn-prov.dtx@info}    \\
%  \cs{svn-prov.dtx@base}    & \@nameuse{svn-prov.dtx@base}    \\
%  \cs{svn-prov.dtx@ext}     & \@nameuse{svn-prov.dtx@ext}     \\
%  \cs{svn-prov.dtx@today}   & \@nameuse{svn-prov.dtx@today}   \\
%  \bottomrule
% \end{tabular}
% \par\bigskip
% The style file however would get macros like \cs{svn-prov@version}.
% Because `|-|' is not a letter the macros can only be accessed using |\csname|.  
% Therefore the optional argument |[svnprov]| is used to name the macros
% \cs{svnprov@version} etc..
% \endgroup
%
%
% \section{Examples}
% \begingroup
% \def\{{\texttt{\char`\{}}%
% \def\}{\texttt{\char`\}}}%
% \def\ProvidesPackage#1[#2]{\texttt{\cs{ProvidesPackage}\{#1\}[#2]}\\}%
% \def\ProvidesClass#1[#2]{\texttt{\cs{ProvidesClass}\{#1\}[#2]}\\}%
% \def\ProvidesFile#1[#2]{\texttt{\cs{ProvidesFile}\{#1\}[#2]}\\}%
%
% The following examples illustrate the usage of the provided macros and how 
% they call the equivalent standard macros internally. The example 
% \emph{results} are produced by expanding the corresponding example \emph{code} 
% while the standard provide macros are locally redefined to typeset their own 
% name and arguments in verbatim style. This does not only simplifies the 
% generation of this document but makes this examples also test cases which 
% allow the package author to test the result of the defined macros.
%
% While mostly the package macro is used here the usage is identical to the 
% class and file macros. Of course before this macros are used it must be made 
% sure that the \texttt{svn-prov} package is loaded which is done by using the 
% following code direct before them:\\[\smallskipamount]
% |\RequirePackage{svn-prov}|\\
%
% \frenchspacing
% \subsubsection*{Minimal usage}
% \begin{example}
%   \ProvidesPackageSVN
%     {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
% \end{example}
% \begin{example}
%   \ProvidesClassSVN
%     {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
% \end{example}
% \begin{example}
%   \ProvidesFileSVN
%     {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
% \end{example}
%
% \subsubsection*{Normal Usage}
% \begin{example}
%   \ProvidesPackageSVN
%     {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
%     [v1.0 Example Description]
% \end{example}
% \begin{example}
%   \ProvidesClassSVN
%     {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
%     [v1.0 Example Description]
% \end{example}
% \begin{example}
%   \ProvidesFileSVN
%     {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
%     [v1.0 Example Description]
% \end{example}
%
% \subsubsection*{Normal Usage with only Description}
% \begin{example}
%   \ProvidesFileSVN
%     {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
%     [Example Description]
% \end{example}
%
% \subsubsection*{Normal Usage with separate Version and Description}
% \begin{example}
%   \ProvidesFileSVN
%     {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
%     [v1.0][Example Description]
% \end{example}
%
% \subsubsection*{Overwriting Name}
% \begin{example}
%   \ProvidesPackageSVN[othername]
%     {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
%     [v1.0 Example Description]
% \end{example}
%
% \subsubsection*{Overwriting Name including unneeded Extension}
% \begin{example}
%   \ProvidesPackageSVN[othername.sty]
%     {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
%     [v1.0 Example Description]
% \end{example}
%
% \subsubsection*{Overwriting Name using Macros}
% \begin{example}
%   \ProvidesFileSVN[\filebase.cfg]
%     {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
%     [v1.0 Example Description]
% \end{example}
%
% \subsubsection*{Using Macros in File Information String}
% \begin{example}
%   \ProvidesPackageSVN
%     {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
%     [v1.\Rev Example Description]
% \end{example}
%
% \subsubsection*{Adding Text to Default Information}
% \begin{example}
%   \ProvidesPackageSVN
%     {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
%     [v1.\Rev Extra Text \revinfo]
% \end{example}
%
% \subsection*{Getting the File Information}
% \def\exampleaftertext{results in:}
% \def\ProvidesPackage#1[#2]{}%
%
% \begin{example}
%   \ProvidesPackageSVN
%     {$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}
%     [v1.\Rev Extra Text \revinfo]
%   \GetFileInfoSVN*
%   % ...
%   \begin{tabular}{l@{\ :\ \ }l}
%     File Name      & \filename    \\
%     File Base Name & \filebase    \\
%     File Extension & \fileext     \\
%     File Date      & \filedate    \\
%     File Revision  & \filerev     \\
%     File Version   & \fileversion \\
%     File Info      & \fileinfo    \\
%   \end{tabular}
% \end{example}
% \noindent
% The correct package file extension `|.sty|' for \cs{fileext} can be forced by 
% using |[\filebase.sty]| as a first optional argument.
%
% \endgroup
% \StopEventually{}
% \manualnewpage
% \section{Implementation}
%
% \iffalse
%<*package>
% \fi
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%    \end{macrocode}
%
% \begin{macro}{\ProvidesClassSVN}
% Calls the generic macro with the original LaTeX macro and the string to be 
% used as filename.
%    \begin{macrocode}
\def\ProvidesClassSVN{%
  \svnprov@generic\ProvidesClass{\svnprov@filebase@}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ProvidesFileSVN}
% Calls the generic macro with the original LaTeX macro and the string to be 
% used as filename.
%    \begin{macrocode}
\def\ProvidesFileSVN{%
  \svnprov@generic\ProvidesFile{\svnprov@filebase@.\svnprov@fileext@}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ProvidesPackageSVN}
% Calls the generic macro with the original LaTeX macro and the string to be 
% used as filename.
%    \begin{macrocode}
\def\ProvidesPackageSVN{%
  \svnprov@generic\ProvidesPackage{\svnprov@filebase@}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\svnprov@generic}
% Stores the arguments (1: original macro, 2: file mask (full filename if only 
% base is used?)). Then tests if a explicit file name was given as optional 
% argument.  If not the file name from the SVN Id string is used.
%    \begin{macrocode}
\def\svnprov@generic#1#2{%
  \def\svnprov@ltxprov{#1}%
  \def\svnprov@filemask{#2}%
  \begingroup
  \svnprov@catcodes
  \@ifnextchar{[}%
    {\svnprov@getid}%
    {\svnprov@getid[\svnprov@svnfilename]}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\svnprov@catcodes}
% Sets the normal catcodes for all characters required by the |getid| macro.
%    \begin{macrocode}
\def\svnprov@catcodes{%
  \catcode`\ =10%
  \catcode`\$=3%
  \@makeother\:%
  \@makeother\-%
}
%    \end{macrocode}
% \end{macro}
%
% Enforce normal catcodes for the definition of the |Id| scanning macros.
% This makes sure that all scan patterns have the same catcodes during definition and execution.
%    \begin{macrocode}
\begingroup
\svnprov@catcodes
%    \end{macrocode}
%
% \begin{macro}{\svnprov@getid}
% Saves first argument as filename and calls the scan macro with the second.
% A fall-back string is provided to avoid \TeX\ parsing errors.
%    \begin{macrocode}
\gdef\svnprov@getid[#1]#2{%
  \endgroup
  \def\svnprov@filename{#1}%
  \svnprov@scanid #2\relax $%
    Id: unknown.xxx 0 0000-00-00 00:00:00Z user $\empty\svnprov@endmarker
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\svnprov@scanid}
% Parses the Id string and tests if it is correct (\#1=empty, \#8=\cs{relax}).
% If correct the values are stored in macros and the next macro is called.
% Otherwise a warning message is printed. In both cases any remaining text of 
% the parsing procedure is gobbled before the next step.
% \begin{macrocode}
\gdef\svnprov@scanid#1$%
  Id: #2 #3 #4-#5-#6 #7 $#8{%
  \def\next{%
    \begingroup
    \PackageWarning{svn-prov}{Invalid SVN Id line found! File name might be
    '#2' or '\expandafter\strip@prefix\meaning\@filef@und'. This occured}{}{}{}%
    \endgroup
    \svnprov@gobbleopt
  }%
  \ifx\relax#1\relax
    \ifx\relax#8\empty
      \def\svnprov@svnfilename{#2}%
      \svnprov@splitfilename{#2}%
      \def\svnprov@filerev@{#3}%
      \def\svnprov@filedate@{#4/#5/#6}%
      \def\svnprov@filetoday@{\svnprov@@today{#4}{#5}{#6}}%
      \def\next{\begingroup\svnprov@catcodes\svnprov@buildstring}%
    \fi
  \fi
  \expandafter\next\svnprov@gobblerest
}% $
%    \end{macrocode}
% \end{macro}
%
% End of area with enforced catcodes.
%    \begin{macrocode}
\endgroup
%    \end{macrocode}
%
% \begin{macro}{\svnprov@@today}
% Prints \cs{today} with the given date.
%    \begin{macrocode}
\def\svnprov@@today#1#2#3{%
  {\year#1\month#2\day#3\relax\today}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\svnprov@splitfilename}
% Expands the argument and initialises the file base macro before it calls the 
% next macro with the expanded argument and a dot to protect for \TeX\ parsing 
% errors. The \cs{relax} is used as end marker.
%    \begin{macrocode}
\def\svnprov@splitfilename#1{%
  \edef\g@tempa{#1}%
  \let\svnprov@filebase@\@gobble
  \expandafter
  \svnprov@splitfilename@\g@tempa.\relax
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\svnprov@splitfilename@}
% The second argument is tested if it is empty (end of file name reached). If 
% not empty the first argument is concatenated to the file base macro and the 
% macro calls itself on the second argument. This ensures correct handling of 
% file name which contain multiple dots.
% 
% If the second argument was empty it is tested if the file base name is still 
% in its initialised state which means that there is no file extension. Then the 
% file base is defined to the first argument and the extension as empty.
% Otherwise the file extension is defined to the first argument and the file 
% base macro is unchanged because it is already correct.
% \begin{macrocode}
\def\svnprov@splitfilename@#1.#2\relax{%
  \if&#2&
    \ifx\svnprov@filebase@\@gobble
      \gdef\svnprov@filebase@{#1}%
      \gdef\svnprov@fileext@{}%
    \else
      \gdef\svnprov@fileext@{#1}%
    \fi
    \let\next\relax
  \else
    \xdef\svnprov@filebase@{\svnprov@filebase@.#1}%
    \def\next{\svnprov@splitfilename@#2\relax}%
  \fi
  \next
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\svnprov@gobblerest}
% Simply gobbles everything up to the next endmarker.
%    \begin{macrocode}
\def\svnprov@gobblerest#1\svnprov@endmarker{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\svnprov@endmarker}
% This is the end marker which should never be expanded. However it gets defined 
% and set to an unique definition which will gobble itself if ever expanded.
%    \begin{macrocode} 
\def\svnprov@endmarker{\@gobble{svn-prov endmarker}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\svnprov@gobbleopt}
% Gobbles an optional argument if present.
%    \begin{macrocode}
\newcommand*\svnprov@gobbleopt[1][]{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\svnprov@defaultdesc}
% Default description text to be used. Does not include the file date which is 
% prepended later.
%    \begin{macrocode}
\def\svnprov@defaultdesc{%
  (SVN Rev:\space\svnprov@filerev@)%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\svnprov@buildstring}
% First aliases the internal macro to user-friendly names and then builds the 
% info string. Finally the stored original LaTeX macro is called with the 
% filename and information.
%    \begin{macrocode}
\newcommand*\svnprov@buildstring[1][\svnprov@defaultdesc]{%
  \@ifnextchar{[}%
    {\svnprov@buildstring@{#1}}%
    {\svnprov@buildstring@{#1}[\relax]}%
}
\def\svnprov@buildstring@#1[#2]{%
  \endgroup
  \begingroup
    \let\rev\svnprov@filerev@
    \let\filerev\svnprov@filerev@
    \def\Rev{\rev\space}%
    \let\revinfo\svnprov@defaultdesc
    \let\filebase\svnprov@filebase@
    \let\fileext\svnprov@fileext@
    \ifx\fileversion\@undefined
      \def\fileversion{v0.0}%
    \fi
    \edef\filename{\filebase.\fileext}%
    \xdef\svnprov@filename{\svnprov@filename}%
    \ifx\svnprov@filename\filename\else
      \svnprov@splitfilename{\svnprov@filename}%
    \fi
    \let\filename\svnprov@filename
    \ifx\relax#2\empty
      \xdef\svnprov@fileinfo@{#1}%
      \svnprov@getversion{#1}%
      \global\let\svnprov@filedesc@\svnprov@filedesc@
      \global\let\svnprov@fileinfo@\svnprov@fileinfo@
    \else
      \xdef\svnprov@fileversion@{#1}%
      \xdef\svnprov@filedesc@{#2}%
      \xdef\svnprov@fileinfo@{#1 #2}%
    \fi
  \endgroup
  \svnprov@ltxprov{\svnprov@filemask}%
    [\svnprov@filedate@
     \ifx\svnprov@fileinfo@\empty\else
      \space
      \svnprov@fileinfo@
     \fi
   ]%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\GetFileInfoSVN}
% \changes{v3.}{2010/04/01}{Added non-star version.}
% The macro provides the file information of the given file, or (the star version) the last file which called one of the above \cs{Provides\ldots} macros.
% For this the internal macros are simply copied to user-friendly names.
%
% This macro is inspired by the macro \cs{GetFileInfo}\marg{file name} from the 
% \texttt{doc} package.
%    \begin{macrocode}
\def\GetFileInfoSVN#1{%
  \ifx*#1\relax
    \let\filebase\svnprov@filebase@
    \let\fileext\svnprov@fileext@
    \let\filename\svnprov@filename
    \let\filedate\svnprov@filedate@
    \let\filerev\svnprov@filerev@
    \let\fileversion\svnprov@fileversion@
    \let\fileinfo\svnprov@filedesc@
    \let\filetoday\svnprov@filetoday@
  \else
%    \end{macrocode}
% Given argument could be filename or short name.
% If a short name exists for the argument it was a filename is is defined as such,
% otherwise the filename is read from the |\|\meta{short name}|@long| macro.
%    \begin{macrocode}
    \expandafter\let\expandafter\@gtempa\csname#1@short\endcsname%
    \ifx\@gtempa\relax
      \def\@gtempa{#1}%
      \expandafter\let\expandafter\filename\csname#1@long\endcsname
    \else
      \edef\filename{#1}%
    \fi
    \expandafter\let\expandafter\filebase\csname\@gtempa @base\endcsname
    \expandafter\let\expandafter\fileext \csname\@gtempa @ext\endcsname
    \expandafter\let\expandafter\filedate\csname\@gtempa @date\endcsname
    \expandafter\let\expandafter\filerev \csname\@gtempa @rev\endcsname
    \expandafter\let\expandafter\fileversion\csname\@gtempa @version\endcsname
    \expandafter\let\expandafter\fileinfo\csname\@gtempa @info\endcsname
    \expandafter\let\expandafter\filetoday\csname\@gtempa @today\endcsname
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DefineFileInfoSVN}
% Defines macros in the form |\|\meta{filename}|@|\meta{xxx}, where \meta{xxx} is |date|, |version|, |rev|(ision), |info|, (file name)|base| and |ext|(ension).
% \changes{v3.}{2010/04/01}{Added file name `base' and 'ext'(ension).}
%    \begin{macrocode}
\newcommand*\DefineFileInfoSVN[1][\svnprov@filemask]{%
  \expandafter
  \edef\csname\svnprov@filemask @short\endcsname{#1}%
  \expandafter
  \edef\csname#1@long\endcsname{\svnprov@filemask}%
  \expandafter
  \let\csname#1@base\endcsname\svnprov@filebase@
  \expandafter
  \let\csname#1@ext\endcsname\svnprov@fileext@
  \expandafter
  \let\csname#1@date\endcsname\svnprov@filedate@
  \expandafter
  \let\csname#1@version\endcsname\svnprov@fileversion@
  \expandafter
  \let\csname#1@rev\endcsname\svnprov@filerev@
  \expandafter
  \let\csname#1@info\endcsname\svnprov@filedesc@
  \expandafter
  \let\csname#1@today\endcsname\svnprov@filetoday@
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\svnprov@getversion}
% Checks if the argument (a file description) starts with `|v|'. If so
% everything until the first space is taken as version number. Otherwise
% the whole text is taken as description without version.
% Special care is taken to avoid a parser error if there is no space included.
% \changes{v3.}{2010/04/01}{Changed to look for leading `v' not just everything up to the first space.}
%    \begin{macrocode}
\def\svnprov@getversion#1{%
  \edef\@tempa{#1\space}%
  \expandafter\svnprov@@getversion\@tempa\svnprov@endmarker
}
\def\svnprov@@getversion{%
  \@ifnextchar{v}%
    {\svnprov@getversion@}%
    {\svnprov@getversion@@}%
}
\def\svnprov@getversion@#1 #2\svnprov@endmarker{%
  \gdef\svnprov@fileversion@{#1}%
  \ifx&#2&%
    \gdef\svnprov@filedesc@{}%
  \else
    \xdef\svnprov@filedesc@{\svnprov@zapspace#2\svnprov@endmarker}%
  \fi
}
\def\svnprov@getversion@@#1 \svnprov@endmarker{%
  \gdef\svnprov@fileversion@{}%
  \gdef\svnprov@filedesc@{#1}%
}
\def\svnprov@zapspace#1 \svnprov@endmarker{#1}
%    \end{macrocode}
% \end{macro}
%
% Finally, call the macros for this package itself.
%    \begin{macrocode}
\ProvidesPackageSVN{$Id: svn-prov.dtx 1862 2010-04-24 14:19:07Z martin $}%
  [\svnprov@version\space Package Date/Version from SVN Keywords]
\DefineFileInfoSVN[svnprov]
%    \end{macrocode}
%
% \iffalse
%</package>
% \fi
%
% \Finale