[109111] trunk/dports/science/gstlal-inspiral/Portfile

Adam Mercer ram at macports.org
Thu Aug 8 09:19:05 PDT 2013


On Thu, Aug 8, 2013 at 10:22 AM, Jeremy Huddleston Sequoia
<jeremyhu at macports.org> wrote:

> I added strndup to Libc in Lion, so it's not available in Snow Leopard.
>
> The fix will be to add a static version of strndup when __MAC_OS_X_VERSION_MIN_REQUIRED < 1070:
> http://opensource.apple.com/source/Libc/Libc-825.26/string/FreeBSD/strndup.c

So adding something like the following to the file that is failing is
the appropriate fix?

/*
 * Mac OS X 10.6 and lower do not contain strndup, define this
 * statically if needed
 */

#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1070
static char *strndup(const char *str, size_t n)
{
  size_t len;
  char *copy;

  for (len = 0; len < n && str[len]; len++)
    continue;

  if ((copy = malloc(len + 1)) == NULL)
    return (NULL);
  memcpy(copy, str, len);
  copy[len] = '\0';
  return (copy);
}
#endif

Cheers

Adam


More information about the macports-dev mailing list