[tex-k] Re: Bug#358330: [tex-live] KPSE_DOT in fmtutil: Why set to `pwd`?

Julian Gilbey jdg at polya.uklinux.net
Mon Mar 27 20:32:43 CEST 2006

[For readers of tex-k: there's a bizarre bug reported at
http://bugs.debian.org/358330 in which fmtutil-sys tries to read the
local user's directory, which it shouldn't.  The bug log contains the
hunt for the source of this problem, and this is a proposed solution.]

On Mon, Mar 27, 2006 at 04:54:05PM +0200, Frank K?ster wrote:
> Julian Gilbey <jdg at polya.uklinux.net> wrote:
> >> So this means that on my system KPSE_DOT is not searched for cnf files,
> >> but it seems to be searched for TEXMF trees?  kpsewhere doesn't show the
> >> local copy, either.
> >
> > That's a bit weird.  And what's it doing traversing the /home/frank
> > tree, anyway?
> >
> > What's your output of kpsewhich --expand-var='$TEXMFCNF' ?
> $ kpsewhich --expand-var='$TEXMFCNF'
> {/usr/bin,/usr,/}{,{/share,}/texmf{-local,}/web2c}::/usr/share/texmf/web2c:/usr/share/texmf/web2c
> $ kpsewhich --expand-braces='$TEXMFCNF'
> /usr/bin:/usr:/:/usr/bin/share/texmf-local/web2c:/usr/share/texmf-local/web2c://share/texmf-local/web2c:/usr/bin/texmf-local/web2c:/usr/texmf-local/web2c://texmf-local/web2c:/usr/bin/share/texmf/web2c:/usr/share/texmf/web2c://share/texmf/web2c:/usr/bin/texmf/web2c:/usr/texmf/web2c://texmf/web2c::/usr/share/texmf/web2c:/usr/share/texmf/web2c
> That's independent of the setting of KPSE_DOT, whereas the error message
> isn't. 

I think I may have found the source of the bug: note that there is an
empty element in the expansion of $TEXMFCNF because TETEXDIR is

What happens is this.  Normally, an empty component in one of the
kpathsea variables will be filled in with the default value from the
next texmf.cnf encountered.  But in the case of TEXMFCNF, this does
not happen (as the compile time version alone is used).

In kpathsea/expand.c, function kpse_expand_kpse_dot, we have the
following code:

  for (elt = kpse_path_element (path); elt; elt = kpse_path_element (NULL)) {
    string save_ret = ret;
    /* We assume that the !! magic is only used on absolute components.
       Single "." gets special treatment, as does "./" or its equivalent. */
    if (kpse_absolute_p (elt, false) || (elt[0] == '!' && elt[1] == '!')) {
      ret = concat3(ret, elt, ENV_SEP_STRING);
    } else if (elt[0] == '.' && elt[1] == 0) {
      ret = concat3 (ret, kpse_dot, ENV_SEP_STRING);
#ifndef VMS
    } else if (elt[0] == '.' && IS_DIR_SEP(elt[1])) {
      ret = concatn (ret, kpse_dot, elt + 1, ENV_SEP_STRING, NULL);
    } else {
      ret = concatn (ret, kpse_dot, DIR_SEP_STRING, elt, ENV_SEP_STRING, NULL);
    free (save_ret);

Now with an empty component, kpse_absolute_p (elt, false) is false, so
we enter the else if part; the first two conditions are false, so we
reach the default:
      ret = concatn (ret, kpse_dot, DIR_SEP_STRING, elt, ENV_SEP_STRING, NULL);
which introduces an unwanted kpse_dot.

I think that the correct solution is to replace the final default else
with the conditional test:

    } else if (elt[0] != 0) {
      /* empty components can appear in TEXMFCNF; we skip over these */


More information about the tex-k mailing list