Skip to content

Commit 02ddf2a

Browse files
Try known extensions in file with dots in the name (fixes #355)
This changes the behaviour when searching graphics files and both 'file.exta' and 'file.exta.extb' exist, and 'exta' is not a known graphics extension. In that case, the list of known extensions is searched, and if 'extb' is valid, that file is tried instead.
1 parent ac93a78 commit 02ddf2a

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

required/graphics/graphics.dtx

+32-22
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
%<driver> \ProvidesFile{graphics.drv}
2626
% \fi
2727
% \ProvidesFile{graphics.dtx}
28-
[2020/08/09 v1.4b Standard LaTeX Graphics (DPC,SPQR)]
28+
[2020/08/30 v1.4c Standard LaTeX Graphics (DPC,SPQR)]
2929
%
3030
% \iffalse
3131
%<*driver>
@@ -1134,30 +1134,40 @@
11341134
\else
11351135
\Gin@getbase{\Gin@sepdefault\filename@ext}%
11361136
% \end{macrocode}
1137-
% At this point try adding an extension, even if the filename has one so
1138-
% that \verb|a.b| may find \verb|a.b.png| if no file is found then revert
1139-
% to the extension as given to get better error reporting.
1137+
% At this point try adding an extension, either if the given file name
1138+
% has none, or if the extension matches no existing graphics inclusion
1139+
% rule, so that \verb|a.b| may find \verb|a.b.png|, if only the latter
1140+
% or if both files exist. If no file is found then revert to the
1141+
% extension as given to get better error reporting.
11401142
%
11411143
% \changes{v1.3d}{2019/11/01}
1142-
% {Try adding an extension even if the filenam had a dot.}
1143-
% \begin{macrocode}
1144-
\ifx\Gin@ext\relax
1145-
\let\Gin@savedbase\filename@base
1146-
\let\Gin@savedext\filename@ext
1147-
\edef\filename@base{\filename@base\Gin@sepdefault\filename@ext}%
1148-
\let\filename@ext\relax
1149-
\@for\Gin@temp:=\Gin@extensions\do{%
1150-
\ifx\Gin@ext\relax
1151-
\Gin@getbase\Gin@temp
1152-
\fi}%
1153-
% \end{macrocode}
1154-
% Restore if no file found using theknown extensions.
1144+
% {Try adding an extension even if the filename had a dot.}
1145+
% \changes{v1.4c}{2020/08/30}
1146+
% {Try adding an extension even if the filename had a dot AND
1147+
% if the filename without the extension exists (but doesn't have
1148+
% a known extension).}
1149+
% \begin{macrocode}
1150+
\ifnum0%
1151+
\ifx\Gin@ext\relax 1%
1152+
\else \@ifundefined{Gin@rule@\Gin@ext}{1}{0}%
1153+
\fi >0
1154+
\let\Gin@ext\relax
1155+
\let\Gin@savedbase\filename@base
1156+
\let\Gin@savedext\filename@ext
1157+
\edef\filename@base{\filename@base\Gin@sepdefault\filename@ext}%
1158+
\let\filename@ext\relax
1159+
\@for\Gin@temp:=\Gin@extensions\do{%
1160+
\ifx\Gin@ext\relax
1161+
\Gin@getbase\Gin@temp
1162+
\fi}%
1163+
% \end{macrocode}
1164+
% Restore if no file found using the known extensions.
11551165
% \begin{macrocode}
1156-
\ifx\Gin@ext\relax
1157-
\let\filename@base\Gin@savedbase
1158-
\let\filename@ext\Gin@savedext
1159-
\fi
1160-
\fi
1166+
\ifx\Gin@ext\relax
1167+
\let\filename@base\Gin@savedbase
1168+
\let\filename@ext\Gin@savedext
1169+
\fi
1170+
\fi
11611171
% \end{macrocode}
11621172
%
11631173
% \begin{macrocode}

0 commit comments

Comments
 (0)