[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Libcdio-devel] [PATCH 1/2] MinGW: detect if strndup is supported an
From: |
Rocky Bernstein |
Subject: |
Re: [Libcdio-devel] [PATCH 1/2] MinGW: detect if strndup is supported and add workaround if not |
Date: |
Mon, 16 Jan 2012 20:23:58 -0500 |
On Mon, Jan 16, 2012 at 8:02 PM, Pete Batard <address@hidden> wrote:
> Couple more patches, since I'm using MinGW.
>
> For what is worth, not much is needed to get MinGW compiling and running
> the samples, at least if all you are interested in is ISO/UDF image
> handling.
>
Good to hear.
>
> Currently, abs_path.c fails to compile because MinGW lacks strndup().
> abs_path.c seems to be the only place that uses it as far as I could see,
> but rather than override strndup always, I added some detection of it to
> configure.ac, so as not to impact other platforms.
>
Thanks taking care to do it this way. Patch as with the others looks fine.
I'm glad to hear someone has tried the new abs_path.c code (added for Leon
Merten Lohse) on Windows.
<https://savannah.gnu.org/users/greenleon>
>
> With this, MinGW compilation completes successfully.
>
> Regards,
>
> /Pete
>
>
> From d20dcbe4637c4bd8de0feba5564d2e2612963a20 Mon Sep 17 00:00:00 2001
> From: Pete Batard <address@hidden>
> Date: Mon, 16 Jan 2012 19:46:06 +0000
> Subject: [PATCH 1/2] MinGW: detect if strndup is supported and add
> workaround
> if not
>
> ---
> configure.ac | 4 ++--
> lib/driver/abs_path.c | 15 +++++++++++++++
> 2 files changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index fbf6e65..47e540c 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -499,8 +499,8 @@ AC_DEFINE_UNQUOTED(LIBCDIO_SOURCE_PATH,
> "$LIBCDIO_SOURCE_PATH",
> AC_SUBST(LIBCDIO_SOURCE_PATH)
>
> AC_CHECK_FUNCS( [bzero chdir drand48 ftruncate geteuid getgid \
> - getuid getpwuid gettimeofday lstat memcpy memset \
> - rand seteuid setegid snprintf setenv unsetenv tzset \
> + getuid getpwuid gettimeofday lstat memcpy memset rand \
> + seteuid setegid snprintf setenv strndup unsetenv tzset \
> sleep usleep vsnprintf readlink realpath gmtime_r
> localtime_r] )
>
> # check for timegm() support
> diff --git a/lib/driver/abs_path.c b/lib/driver/abs_path.c
> index 4588e93..9b01489 100644
> --- a/lib/driver/abs_path.c
> +++ b/lib/driver/abs_path.c
> @@ -59,6 +59,21 @@
> # define CharNext(p) ((p) + 1)
> #endif
>
> +#ifndef HAVE_STRNDUP
> +static inline char *strndup(const char *s, size_t n)
> +{
> + char *result;
> + size_t len = strlen (s);
> + if (n < len)
> + len = n;
> + result = (char *) malloc (len + 1);
> + if (!result)
> + return 0;
> + result[len] = '\0';
> + return (char *) strncpy (result, s, len);
> +}
> +#endif /*HAVE_STRNDUP*/
> +
> static char *
> strrdirsep(const char *path)
> {
> --
> 1.7.8.msysgit.0
>
>
>