Re: [RFC PATCH] configure: check for POSIX.1-2008 realpath(3) implementation.

Subject: Re: [RFC PATCH] configure: check for POSIX.1-2008 realpath(3) implementation.

Date: Sat, 25 Jan 2014 20:55:35 -0400

To: Tomi Ollila, notmuch@notmuchmail.org

Cc: tomi.ollila@iki.fi

From: David Bremner


Tomi Ollila <tomi.ollila@iki.fi> writes:
> +#if POSIX_2008_REALPATH
>      filename = realpath (config->filename, NULL);
> +#else
> +    /* compatibility with minor effort, not elegance, is the ruling factor
> +       in these (two) else branches... */
> +    char resolved_path[PATH_MAX];
> +    filename = realpath (config->filename, resolved_path);
> +#endif
>      if (! filename) {
>  	if (errno == ENOENT) {
> +#if POSIX_2008_REALPATH
>  	    filename = strdup (config->filename);
> +#else
> +	    /* ... this is the other else... */
> +	    resolved_path[sizeof resolved_path - 1] = '\0';
> +	    strncpy(resolved_path, config->filename, sizeof resolved_path);
> +	    /* "faking" out of memory in case path too long -- close enough? */
> +	    filename = resolved_path[sizeof resolved_path - 1]?
> +		resolved_path: NULL;
> +#endif

I worry a bit about making the mainline code messier and harder to maintain, in order to
accomodate an unknown number of targets without POSIX2008 realpath. Do
we know how widespread this problem is? Is it just NetBSD?

I looked at borrowing realpath from gnulib; it looks like it would be a
bit of work as the least complicated version includes 3 other include
files. But then the mainline code could be blisfully ignorant of the
whole dispute.

d


Thread: