summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/oberdiek/grffile.sty
blob: 829dbbcd6da6f3422b66e5282acfe0d382488c56 (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
%%
%% This is file `grffile.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% grffile.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2006-2008 by Heiko Oberdiek <oberdiek@uni-freiburg.de>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3 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.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% This Current Maintainer of this work is Heiko Oberdiek.
%% 
%% This work consists of the main source file grffile.dtx
%% and the derived files
%%    grffile.sty, grffile.pdf, grffile.ins, grffile.drv,
%%    grffile-test1.tex.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{grffile}%
  [2008/10/13 v1.9 Extended file name support for graphics (HO)]%
\edef\grffile@RestoreCatcodes{%
  \catcode`\noexpand\=\the\catcode`\=\relax
  \catcode`\noexpand\:\the\catcode`\:\relax
  \catcode`\noexpand\.\the\catcode`\.\relax
  \catcode`\noexpand\'\the\catcode`\'\relax
  \catcode`\noexpand\<\the\catcode`\<\relax
  \catcode`\noexpand\>\the\catcode`\>\relax
  \catcode`\noexpand\*\the\catcode`\*\relax
  \catcode`\noexpand\^\the\catcode`\^\relax
  \catcode`\noexpand\~\the\catcode`\~\relax
}
\@makeother\=
\@makeother\:
\@makeother\.
\@makeother\'
\@makeother\<
\@makeother\>
\@makeother\*
\catcode`\^=7 %
\catcode`\~=\active
\RequirePackage{ifpdf}
\RequirePackage{kvoptions}[2006/08/17]
\SetupKeyvalOptions{%
  family=Gin,%
  prefix=grffile@%
}
\DeclareBoolOption[true]{multidot}
\DeclareBoolOption[true]{babel}
\DeclareBoolOption[false]{extendedchars}
\DeclareBoolOption{space}
\DeclareVoidOption{encoding}{%
  \RequirePackage{stringenc}\relax
}
\DeclareStringOption{inputencoding}
\DeclareStringOption{filenameencoding}
\DeclareDefaultOption{%
  \PassOptionsToPackage\CurrentOption{graphics}%
}
\RequirePackage{pdftexcmds}[2007/11/11]
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname pdf@filesize\endcsname\relax
  \grffile@spacefalse
  \let\grffile@space@disabled\@empty
  \def\grffile@spacetrue{%
    \PackageWarning{grffile}{%
      Option `space' is not available,\MessageBreak
      because it needs pdfTeX >= 1.30%
    }%
  }%
\else
  \ifpdf
    \grffile@spacetrue
  \else
    \grffile@spacefalse
  \fi
\fi
\ProcessKeyvalOptions*
\AtBeginDocument{%
  \DisableKeyvalOption[package=grffile]{Gin}{encoding}%
}
\RequirePackage{graphics}
\newcommand*{\grffilesetup}{%
  \setkeys{Gin}%
}
\let\grffile@org@Ginclude@graphics\Ginclude@graphics
\renewcommand*{\Ginclude@graphics}{%
  \ifx\grffile@filenameencoding\@empty
  \else
    \ifx\grffile@inputencoding\@empty
      \expandafter\ifx\csname inputencodingname\endcsname\relax
        \expandafter\ifx\csname
            CurrentInputEncodingOption\endcsname\relax
        \else
          \let\grffile@inputencoding\CurrentInputEncodingOption
        \fi
      \else
        \let\grffile@inputencoding\inputencodingname
      \fi
    \fi
    \ifx\grffile@inputencoding\@empty
    \else
      \grffile@extendedcharstrue
    \fi
  \fi
  \ifnum0\ifgrffile@babel 1\fi\ifgrffile@extendedchars 1\fi>\z@
    \begingroup
      \ifgrffile@babel
        \csname @safe@activestrue\endcsname
        \edef~{\string~}%
      \fi
      \ifgrffile@extendedchars
        \grffile@inputenc@loop\^^A\^^H%
        \grffile@inputenc@loop\^^K\^^K%
        \grffile@inputenc@loop\^^N\^^_%
        \grffile@inputenc@loop\^^?\^^ff%
      \fi
      \expandafter\grffile@extchar@Ginclude@graphics
  \else
    \expandafter\grffile@Ginclude@graphics
  \fi
}
\def\grffile@extchar@Ginclude@graphics#1{%
  \def\grffile@filename{#1}%
  \ifx\grffile@inputencoding\@empty
  \else
    \ifx\grfile@filenameencoding\@empty
    \else
      \ifx\grffile@inputencoding\grffile@filenameencoding
      \else
        \expandafter\ifx\csname StringEncodingConvert\endcsname\relax
          \PackageError{grffile}{%
            Package `stringenc' is not loaded,\MessageBreak
            omitting file name conversion%
          }\@ehc
        \else
          \StringEncodingConvert\grffile@temp\grffile@filename
              \grffile@inputencoding\grffile@filenameencoding
          \StringEncodingSuccessFailure{%
            \let\grffile@filename\grffile@temp
          }{%
            \PackageError{grffile}{%
              Filename conversion failed%
            }\@ehc
          }%
        \fi
      \fi
    \fi
  \fi
  \edef\x{\endgroup
    \noexpand\grffile@Ginclude@graphics{\grffile@filename}%
  }%
  \x
}
\def\grffile@inputenc@loop#1#2{%
  \count@=`#1\relax
  \loop
    \begingroup
      \uccode`\~=\count@
    \uppercase{%
      \endgroup
      \edef~{\string~}%
    }%
  \ifnum\count@<`#2\relax
    \advance\count@\@ne
  \repeat
}
\def\grffile@space@getbase#1{%
  \edef\grffile@tempa{%
    \def\noexpand\@tempa####1#1\noexpand\@nil{%
      \def\noexpand\Gin@base{####1}%
    }%
  }%
  \grffile@IfFileExists{\filename@area\filename@base#1}{%
    \grffile@tempa
    \expandafter\@tempa\grffile@file@found\@nil
    \edef\Gin@ext{#1}%
  }{%
  }%
}
\def\grffile@IfFileExists#1{%
  \expandafter\expandafter\expandafter
  \ifx\expandafter\expandafter\expandafter\\\pdf@filesize{#1}\\%
    \let\reserved@a\@secondoftwo
    \ifx\input@path\@undefined
    \else
      \expandafter\@tfor\expandafter\reserved@b\expandafter
          :\expandafter=\input@path\do{%
        \expandafter\expandafter\expandafter
        \ifx\expandafter\expandafter\expandafter
            \\\pdf@filesize{\reserved@b#1}\\%
        \else
          \edef\grffile@file@found{\reserved@b#1}%
          \let\reserved@a\@firstoftwo
          \@break@tfor
        \fi
      }%
    \fi
    \expandafter\reserved@a
  \else
    \edef\grffile@file@found{#1}%
    \expandafter\@firstoftwo
  \fi
}

\def\grffile@Ginclude@graphics#1{%
  \begingroup
    \ifgrffile@space
      \let\Gin@getbase\grffile@space@getbase
    \fi
    \ifgrffile@multidot
      \let\filename@base\@empty
      \let\filename@simple\grffile@filename@simple
    \fi
    \grffile@org@Ginclude@graphics{#1}%
  \endgroup
}%

\def\grffile@filename@simple#1.#2\\{%
  \ifx\\#2\\%
    \ifx\filename@base\@empty
      \let\filename@ext\relax
    \else
      \grffile@ReturnAfterFiFiBase{%
        \edef\filename@base{\expandafter\filename@dot\filename@base\\}%
        \edef\filename@ext{#1}%
      }%
    \fi
  \else
    \expandafter\ifx\csname
        Gin@rule@.\filename@dot #2\\\endcsname\relax
      \edef\filename@base{\filename@base #1.}%
      \grffile@ReturnAfterFiFiBase{\grffile@filename@simple #2\\}%
    \else
      \edef\filename@ext{\filename@dot #2\\}%
    \fi
  \fi
  \edef\filename@base{\filename@base #1}%
}
\def\grffile@ReturnAfterFiFiBase#1#2\fi\edef\filename@base#3{\fi\fi#1}
\def\grffile@option@status#1{%
  \begingroup
    \let\on@line\@empty
    \PackageInfo{grffile}{%
      Option `#1' is %
      \expandafter\ifx\csname ifgrffile@#1\expandafter\endcsname
                      \csname iftrue\endcsname
        set to `true'%
      \else
        \expandafter\ifx\csname grffile@#1@disabled\endcsname\@empty
          not available%
        \else
          set to `false'%
        \fi
      \fi
    }%
  \endgroup
}
\grffile@option@status{multidot}
\grffile@option@status{extendedchars}
\grffile@option@status{space}
\grffile@RestoreCatcodes
\endinput
%%
%% End of file `grffile.sty'.