kpathsea: File lookup
6.2 File lookup
===============
This section describes how Kpathsea searches for most files (bitmap font
searches are the exception, as described in the next section).
Here is the search strategy for a file NAME:
1. If the file format defines default suffixes, and the suffix of NAME
name is not already a known suffix for that format, try the name
with each default appended, and use alternative names found in the
fontmaps if necessary. Example: given 'foo.bar', look for
'foo.bar.tex'.
2. Search for NAME, and if necessary for alternative names found in
the fontmaps. Example: given 'foo.bar', we also look for
'foo.bar'.
3. If the file format defines a program to invoke to create missing
files, run it (⇒mktex scripts).
The order in which we search for "suffixed" name (item 1) or the
"as-is" name (item 2) is controlled by the 'try_std_extension_first'
configuration value. The default set in 'texmf.cnf' is true, since
common suffixes are already recognized: 'babel.sty' will only look for
'babel.sty', not 'babel.sty.tex', regardless of this setting.
When the suffix is unknown (e.g., 'foo.bar'), both names are always
tried; the difference is the order in which they are tried.
'try_std_extension_first' only affects names being looked up which
*already* have an extension. A name without an extension (e.g., 'tex
story') will always have an extension added first.
This algorithm is implemented in the function 'kpathsea_find_file' in
the source file 'kpathsea/tex-file.c'. You can watch it in action with
the debugging options (⇒Debugging).