[tex-k] Re: kpathsearch and Octave

Olaf Weber olaf@infovore.xs4all.nl
25 Oct 2002 21:44:12 +0200

John W Eaton writes:

> On 25-Oct-2002, Olaf Weber <olaf@infovore.xs4all.nl> wrote:
> | John W Eaton writes:
> | 
> | > First, Octave is interactive, and users may change the value of the
> | > path used for searching for functions at any time, so I need to be
> | > able to clear the directory cache and start fresh.  The patch below
> | > adds a new function for this purpose.
> | 
> | Do you really need to clear the directory cache for this?  I _think_
> | just picking a different search path should already work, but I may be
> | completely off.  (Unless the resulting "memory leak" is your concern.)

> I don't see any code that removes directories from the cache.

That's because there is no such code at present.

> Suppose there are two directories /foo and /bar that contain the same
> file X.  Then if the user starts out with /foo in the path and looks
> up X, they will find /foo/X, and that's fine.  Now they change the
> path to /bar, and they should find /bar/X.  Is that what will happen?

Yes -- when you look for 'X', entries for /foo/X and /bar/X are both
found in the hash table, and then matched to the given path.  Only if
it is actually on the search path will the entry be returned.  The
code relies on this in several ways -- for example, a few duplicate
entries tend to be present in the default texmf tree, and therefore
also in the database that is built from the ls-R.  We use different
search paths to ensure that we find one entry instead of another.

> What about if /foo/X exists and the user simply removes /foo from the
> path?  Does it remain in the cache, so it will still be found, even
> though the user has removed /foo from the path?

The /foo/X entry is still in the database, but if someone searches for
X along path that doesn't include /foo, it will not be found.

> | Outside of the web2c sources, to be precise.  I do recognize this as a
> | problem, but properly disentangling libkpathsea from web2c will take
> | some effort.  In particular, there are parts of the build system that
> | I'm looking at and would like to change/clean up.  I am also not happy
> | with the library interface when looked at as a shared library
> | interface, and I'm profoundly unhappy with the headers that have to be
> | installed.

> OK.

> I think that this library could have a lot of uses beyond TeX and
> web2c.  It would be nice to extract the basic path searching stuff
> into a base library with a nice clean interface that could be used by
> lots of different projects, and then build the TeX-specific stuff on
> top of that.  I'd be willing to help (as much as I can, given my
> limited time) make that happen if it is something that you agree would
> be useful.

I may have questions for you later.

By the way, this reminder of yours did come at a good moment, as we
haven't quite frozen the code for the next web2c yet.

Olaf Weber

               (This space left blank for technical reasons.)