Re: Need advice if changes to file_5.04-6 enabling build on GNU/Hurd are OK?
Hi,
On Thu, Feb 10, 2011 at 12:18:59AM +0100, Svante Signell wrote:
> The pattern I used for the patch was
> +#ifdef __GLIBC__
> + char * subfn;
> +#else
> + char subfn[MAXPATHLEN];
> +#endif
> + char **filearr = NULL, *mfn;
>
> +#ifdef __GLIBC__
> + (void)asprintf (&subfn, "%s/%s",
> + fn, d->d_name);
> +#else
> + (void)snprintf (subfn, sizeof(subfn), "%s/%s",
> + fn, d->d_name);
> +#endif
Hope you also have a free(subfn) somewhere in there :-)
> Should I use #ifdef HAVE_ASPRINTF and #ifdef HAVE_GETLIE instead?
Well, it's a largely a matter of taste. IMHO it would be more elegant to
use asprintf() whenever available -- but depending on the upstream
maintainer's belief system, it *might* be preferable to only use it if
it's strictly necessary, i.e. if MAXPATHLEN doesn't exist...
(Ignoring the fact that in theory at least, MAXPATHLEN could be a large
value, making the static approach unsuitable even when MAXPATHLEN
exists.)
I'd suggest proposing a patch with whatever you personally prefer, and
see how upstream reacts.
-antrik-
Reply to: