Re: 2.96.4 beta build reports
"George N. White III" <[email protected]>
| Newsgroups | gmane.comp.tex.tetex.beta |
|---|---|
| Organization | Bedford Institute of Oceanography |
| Message-ID | <[email protected]> |
On Thu, 8 Jul 2004, Thomas Esser wrote:
> On Wed, Jul 07, 2004 at 03:42:29PM -0300, George N. White III wrote:
>> "xdvi.h" defines MAXPATHLEN, so a quick fix was to edit
>> "print-internal.c" and "util.c" to replace PATH_MAX with MAXPATHLEN..
>
> kpathsea/c-pathmx.h seems to sole this in a better way. Stefan, do
> you agree? Will you set up an appropriate #include somewhere?
The relevant section of c-pathmx.h says:
----------------------------------------
/* Cheat and define this as a manifest constant no matter what, instead
of using pathconf. I forget why we want to do this. */
----------------------------------------
which doesn't inspire confidence, although consistency is a virtue for
this sort of cheating. In any case, it shouldn't be an issue on platforms
that define MAXPATHLEN in <sys/param.h>, which is brought in by
<kpathsea/c-limits.h>.
A reason for avoiding pathconf() is given in the BUGS section of "man
realpath" (on Knoppix):
---------------------
BUGS
Never use this function. It is broken by design since it is impossible
to determine a suitable size for the output buffer. According to POSIX
a buffer of size PATH_MAX suffices, but PATH_MAX need not be a defined
constant, and may have to be obtained using pathconf(). And asking
pathconf() does not really help, since on the one hand POSIX warns that
the result of pathconf() may be huge and unsuitable for mallocing mem-
ory. And on the other hand pathconf() may return -1 to signify that
PATH_MAX is not bounded.
--------------------
I looked at what the R-Project does, since it is used on much the
same range of platforms that teTeX supports:
R-1.9.1 src/include/Defn.h
/* Maximal length of an entire file name */
#if !defined(PATH_MAX)
# if defined(HAVE_SYS_PARAM_H)
# include <sys/param.h>
# endif
# if !defined(PATH_MAX)
# if defined(MAXPATHLEN)
# define PATH_MAX MAXPATHLEN
# elif defined(Win32)
# define PATH_MAX 260
# else
/* quite possibly unlimited, so we make this large, and test when used */
# define PATH_MAX 5000
# endif
# endif
#endif
The key difference is that the kpathsea/c-pathmx.h assumes a small
PATH_MAX if neither PATH_MAX nor MAXPATHLEN can be determined, while
R-Project assumes they are probably "unlimited", so sets a value
suitable for use with malloc.
--
George N. White III <[email protected]>
Head of St. Margarets Bay, Nova Scotia, Canada