Bug#259390: tetex-bin: Mistake in processing a filename
On 16.07.04 Ajay Shah (ajayshah@mayin.org) wrote:
Hi,
> > As I assume this to be a missing feature instead of a bug I'm
> > setting the severity to wishlist. We (in the DBTS) probably won't
> > fix it, so I tag it wontfix. We'll come back to it, if the
> > described situation will change, but I have doubt that this will
> > happen.
>
> I would respectfully like to say that from an end-user perspective,
> this is a horrible and incompetent bug. I am a geek and I'm
> perfectly okay with the workarounds (I just switched from '.' to
> '_'). But to tell a lay user that
>
> \includegraphics{last.year.revenue.pdf}
>
> will not work: it makes us look incompetent.
>
> This aspect needs to be communicated to the developers.
>
Heiko Oberdiek was so kind to write a workaround I attach here.
That package is not official in any way, but it does what you
request. It would be nice if you could give it a thorough test and
then report back.
Kind regards,
Hilmar
--
sigmentation fault
%%% cut %%% grffile.sty %%% cut %%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{grffile}%
[2004/07/18 v0.5 Extended file name support for graphics (HO)]
% The package defines three options that allows a larger range
% of file names that can be used with graphics or graphicx.
%
% "multidot"
%
% The file name parsing is changed, in order to detect
% known extensions. This allows both the use of dots inside the
% base name and extensions with several dots.
%
% Example:
% \usepackage[multidot]{grffile}
%
% % Files: Hello.World.eps, Hello.World.pdf
% \includegraphics{Hello.World}
% % will find "Hello.World.pdf" with driver "pdftex"
% % or "Hello.World.eps" with driver "dvips".
%
% "extendedchars"
%
% If the input encoding is the same encoding as the encoding that
% is used for file names and the driver allows non-asscii characters,
% then this option can be used to try file names with such characters.
%
% Example:
% \usepackage[latin1]{inputenc}
% \usepackage[extendedchars]{grffile}
% \includegraphics{Bäckerstraße}
%
% If "draft" is enabled, the file name is printed with the
% current font encoding for \ttfamily. Thus it is possible,
% that such characters are omitted or the wrong characters
% are displayed, if the font encoding is not the same as
% the file name encoding.
%
% "nofilecheck"
%
% \TeX\ considers the space character as termination in its
% syntax for commands that expect a file name.
% Therefore files with spaces cannot be used with TeX.
% However, pdfTeX's primitive \pdfximage that is used for
% including file names uses curly braces to delimit the
% file name, so spaces are possible.
% But the \TeX's limitation applies for some operations
% of the graphics package:
% * Print a warning message, if the file cannot be found.
% * If a file name is given without extension, then graphics
% looks for an existent file with a supported file extension.
% Both relies on existence checks that are done by TeX's
% limited primitives.
%
% Option "nofilecheck" disables both features to allow
% files with spaces. This works for pdf\TeX, if the
% file is given with extension. But beware, many of the other
% drivers does not expect spaces in file names and this can
% lead to errors in the process chain after the \LaTeX\ run.
%
% Example:
% \usepackage[pdftex]{graphics}
% \usepackage[multidot]{grffile}
%
% \includegraphics{Hello World.pdf}% the extension must be given
%
% Use
%
% The options can be given at many places:
%
% a) Package: \usepackage[<options>]{grffile}
%
% The following possibilities are supported, if package graphicx
% is used:
%
% b) Graphics configuration: \setkeys{Gin}{<options>}
%
% c) Applying of options for just one file:
% \includegraphics[<options>]{...}
%
\newif\ifGin@multidot
\newif\ifGin@extendedchars
\newif\ifGin@nofilecheck
\DeclareOption{multidot}{\Gin@multidottrue}
\DeclareOption{extendedchars}{\Gin@extendedcharstrue}
\DeclareOption{nofilecheck}{\Gin@nofilechecktrue}
\DeclareOption*{\PassOptionsToPackage\CurrentOption{graphics}}
\ProcessOptions\relax
\RequirePackage{graphics}
% Support for graphicx
% Test for \define@key without defining it
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname define@key\endcsname\relax
% package keyval is not loaded yet, thus its definitions
% are used here to define the new options.
% \@ifnextchar and \@namedef are provided by miniltx.tex.
\def\Gin@define@key#1#2{%
\@ifnextchar[{%
\Gin@KV@def{#1}{#2}%
}{%
\@namedef{KV@#1@#2}####1%
}%
}%
\def\Gin@KV@def#1#2[#3]{%
\@namedef{KV@#1@#2@default\expandafter}\expandafter
{\csname KV@#1@#2\endcsname{#3}}%
\@namedef{KV@#1@#2}##1%
}%
\else
\let\Gin@define@key\define@key
\fi
\Gin@define@key{Gin}{nofilecheck}[true]{%
\lowercase{\Gin@boolkey{#1}}{nofilecheck}%
}
\Gin@define@key{Gin}{multidot}[true]{%
\lowercase{\Gin@boolkey{#1}}{multidot}%
}
\Gin@define@key{Gin}{extendedchars}[true]{%
\lowercase{\Gin@boolkey{#1}}{extendedchars}%
}
% paranoid catcode settings
\edef\Gin@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
}
\@makeother\=
\@makeother\:
\@makeother\.
\@makeother\'
\@makeother\<
\catcode`\*=11 %
\catcode`\^=7 %
\catcode`\~=\active
\expandafter\renewcommand\string *{\Ginclude@graphics}[1]{%
\begingroup
\ifGin@extendedchars
% babel characters
\csname @safe@activestrue\endcsname
% active ~
\edef~{\string~}%
% inputenc characters
\Gin@inputenc@loop\^^A\^^H%
\Gin@inputenc@loop\^^K\^^K%
\Gin@inputenc@loop\^^N\^^_%
\Gin@inputenc@loop\^^?\^^ff%
\fi
\let\input@path\Ginput@path
\ifGin@multidot
\let\filename@simple\Gin@filename@simple
\let\filename@base\@empty
\fi
\filename@parse{#1}%
\ifx\filename@ext\relax
\ifGin@nofilecheck
\else
\@for\Gin@temp:=\Gin@extensions\do{%
\ifx\Gin@ext\relax
\Gin@getbase\Gin@temp
\fi
}%
\fi
\else
\ifGin@nofilecheck
\edef\Gin@base{\filename@area\filename@base}%
\edef\Gin@ext{\Gin@sepdefault\filename@ext}%
\else
\Gin@getbase{\Gin@sepdefault\filename@ext}%
\ifx\Gin@ext\relax
\@warning{File `#1' not found}%
\def\Gin@base{\filename@area\filename@base}%
\edef\Gin@ext{\Gin@sepdefault\filename@ext}%
\fi
\fi
\fi
\ifx\Gin@ext\relax
\@latex@error{File `#1' not found}%
{I could not locate the file with any of these %
extensions:^^J%
\Gin@extensions^^J\@ehc}%
\else
\@ifundefined{Gin@rule@\Gin@ext}{%
\ifx\Gin@rule@*\@undefined
\@latex@error{Unknown graphics extension: \Gin@ext}\@ehc
\else
\expandafter\Gin@setfile\Gin@rule@*{\Gin@base\Gin@ext}%
\fi
}{%
\expandafter\expandafter\expandafter\Gin@setfile
\csname Gin@rule@\Gin@ext\endcsname{\Gin@base\Gin@ext}%
}%
\fi
\endgroup
}
\def\Gin@inputenc@loop#1#2{%
\count@=`#1\relax
\loop
\begingroup
\uccode`\~=\count@
\uppercase{%
\endgroup
\edef~{\string~}%
}%
\ifnum\count@<`#2\relax
\advance\count@\@ne
\repeat
}
\def\Gin@filename@simple#1.#2\\{%
\ifx\\#2\\%
\let\filename@ext\relax
\else
\expandafter\ifx\csname
Gin@rule@.\filename@dot #2\\\endcsname\relax
\edef\filename@base{\filename@base #1.}%
\Gin@ReturnAfterFiFiBase{\Gin@filename@simple #2\\}%
\else
\edef\filename@ext{\filename@dot #2\\}%
\fi
\fi
\edef\filename@base{\filename@base #1}%
}
\def\Gin@ReturnAfterFiFiBase#1#2\filename@base#3{\fi\fi#1}
\Gin@RestoreCatcodes
\endinput
%%% cut %%% grffile.sty %%% cut %%%
Reply to: