blob: 9697d4679c2d370c5f899a48a9e30a8fe906405d (
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
|
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{currfile}[%
2011/09/18
v0.5
ydoc package to describe macros, environments, options etc.]
\RequirePackage{kvoptions}
\SetupKeyvalOptions{family=currfile,prefix=currfile@}
\@ifpackageloaded{fink}{%
\DeclareStringOption[\fnk@mainext]{mainext}%
\DeclareStringOption[\fnk@maindir]{maindir}%
\DeclareBoolOption[true]{fink}%
\PackageWarning{currfile}{Deprecated package 'fink' detected. %
The 'fink' option will default to 'true'.^^J%
If set to 'false' no 'fink' macros will be changed but they will stop
working correctly!}%
}{%
\DeclareStringOption[tex]{mainext}%
\DeclareStringOption[\@currdir]{maindir}%
\DeclareBoolOption[false]{fink}%
}%
\DeclareVoidOption{force}{\PassOptionsToPackage{force}{filehook}}
\RequirePackage{filehook}[2011/01/09]
\ProcessKeyvalOptions*\relax
\begingroup
\xdef\currfile@mainext{\currfile@mainext}%
\xdef\currfile@maindir{\currfile@maindir}%
\def\@tempa{./}%
\ifx\@tempa\currfile@maindir
\global\let\currfile@maindir\empty
\fi
\endgroup
\filehook@prefixwarg\filehook@every@atbegin{%
\currfile@push
\currfile@set{#1}%
}
\filehook@appendwarg\filehook@every@atend{%
\currfile@pop
}
\def\currfile@set#1{%
\begingroup
\edef\@filef@und{#1}%
\ifx\input@path\@undefined\else
\currfile@checkpath
\fi
\@onelevel@sanitize\@filef@und
\let\filename@simple\currfile@parseext
\let\filename@base\@gobble
\expandafter\filename@parse\expandafter{\@filef@und}%
\global\let\currfiledir\filename@area
\global\let\currfilebase\filename@base
\global\let\currfileext\filename@ext
\xdef\currfilename{\currfilebase\ifx\currfileext\@empty\else.\currfileext\fi}%
\xdef\currfilepath{\currfiledir\currfilename}%
\endgroup
}
\def\currfile@checkpath{%
\openin\@inputcheck\@filef@und\relax
\ifeof\@inputcheck
\expandafter\@tfor
\expandafter\@tempb
\expandafter:\expandafter=\input@path\do{%
\openin\@inputcheck\@tempb\@filef@und\relax
\ifeof\@inputcheck\else
\edef\@filef@und{\@tempb\@filef@und}%
\@break@tfor
\fi
}%
\fi
\closein\@inputcheck
}
\begingroup
\@makeother{.}
\gdef\currfile@parseext#1.#2\\{%
\ifx\\#2\\%
\ifx\filename@base\@gobble
\def\filename@base{#1}%
\let\filename@ext\currfile@defaultext%
\else
\def\filename@ext{#1}%
\fi
\else
\edef\filename@base{\filename@base.#1}%
\def\@tempa{\currfile@parseext#2\\}%
\expandafter\@tempa
\fi
}
\endgroup
\def\currfile@defaultext{tex}
\@onelevel@sanitize\currfile@defaultext
\def\currfile@push{%
\xdef\currfile@stack{%
{\currfiledir}%
{\currfilebase}%
{\currfileext}%
\currfile@stack
}%
}
\def\currfile@pop{%
\ifx\currfile@stack\empty
\PackageWarning{currfile}{File stack underflow!}%
\global\let\currfile@stack\currfile@stackinit
\fi
\expandafter\currfile@pop@\currfile@stack\relax
\relax\relax\relax
}
\def\currfile@pop@#1#2#3#4\relax{%
\gdef\currfiledir{#1}%
\gdef\currfilebase{#2}%
\gdef\currfileext{#3}%
\xdef\currfilename{\currfilebase\ifx\currfileext\empty\else.\currfileext\fi}%
\xdef\currfilepath{\currfiledir\currfilename}%
\gdef\currfile@stack{#4}%
}
\def\currfile@stack{}
\currfile@set{\currfile@maindir\jobname.\currfile@mainext}
\currfile@push
\let\currfile@stackinit\currfile@stack
\newcommand*\ifcurrfilename{\begingroup\currfile@if\currfilename}
\newcommand*\ifcurrfilebase{\begingroup\currfile@if\currfilebase}
\newcommand*\ifcurrfileext{\begingroup\currfile@if\currfileext}
\newcommand*\ifcurrfiledir{\begingroup\currfile@if\currfiledir}
\newcommand*\ifcurrfilepath{\begingroup\currfile@if\currfilepath}
\newcommand*\ifcurrfile[1]{%
\begingroup
\edef\@tempb{#1}%
\@onelevel@sanitize\@tempb
\currfile@if\@tempb
}
\def\currfile@if#1#2{%
\edef\@tempa{#2}%
\@onelevel@sanitize\@tempa
\ifx\@tempa#1%
\endgroup
\expandafter\@firstoftwo
\else
\endgroup
\expandafter\@secondoftwo
\fi
}
\ifcurrfile@fink
\def\finkfile{\currfilename}%
\def\finkdir{\currfiledir}%
\def\finkpath{\currfilepath}%
\def\finkbase{\currfilebase}%
\def\finkext{\currfileext}%
\@ifpackageloaded{fink}{%
\def\fink@restore#1{}%
}{%
\@namedef{ver@fink.sty}{2011/01/09}%
\expandafter\edef\csname opt@fink.sty\endcsname{%
maindir=\currfile@maindir,mainext=\currfile@mainext
}%
}%
\else
\@ifpackageloaded{fink}{}{%
\AtBeginOfPackageFile{fink}{%
\PackageError{currfile}{The 'fink' package is now deprecated. %
Load 'currfile' with the 'fink' option or see the upgrade guide in the manual}{}%
}%
}%
\fi
\endinput
%%
%% End of file `currfile.sty'.
|