Use config.h to test for the availability of strndup() and strnlen().
(cherry picked from commit 541679d6513ce0c4fc257b2b6f6708e5819c84eb)
This commit is contained in:
parent
60c9e95637
commit
348bf19412
@ -244,6 +244,10 @@ Version 1.8.0
|
|||||||
Version 1.6.11
|
Version 1.6.11
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
|
2011-01-16 Marcelo Roberto Jimenez <mroberto(at)users.sourceforge.net>
|
||||||
|
|
||||||
|
Use config.h to test for the availability of strndup() and strnlen().
|
||||||
|
|
||||||
2011-01-14 Chandra Penke <chandrapenke(at)mcntech.com>
|
2011-01-14 Chandra Penke <chandrapenke(at)mcntech.com>
|
||||||
|
|
||||||
- Null termination of strndup() implementation on systems missing it.
|
- Null termination of strndup() implementation on systems missing it.
|
||||||
|
@ -49,6 +49,12 @@
|
|||||||
/* Define to 1 if you have the <string.h> header file. */
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
#define HAVE_STRING_H 1
|
#define HAVE_STRING_H 1
|
||||||
|
|
||||||
|
/* Defines if strndup is available on your system */
|
||||||
|
#define HAVE_STRNDUP 1
|
||||||
|
|
||||||
|
/* Defines if strnlen is available on your system */
|
||||||
|
#define HAVE_STRNLEN 1
|
||||||
|
|
||||||
/* Define to 1 if you have the <syslog.h> header file. */
|
/* Define to 1 if you have the <syslog.h> header file. */
|
||||||
#define HAVE_SYSLOG_H 1
|
#define HAVE_SYSLOG_H 1
|
||||||
|
|
||||||
|
@ -499,6 +499,10 @@ fi
|
|||||||
#
|
#
|
||||||
AC_FUNC_VPRINTF
|
AC_FUNC_VPRINTF
|
||||||
AC_FUNC_FSEEKO
|
AC_FUNC_FSEEKO
|
||||||
|
AC_CHECK_FUNC(strnlen,
|
||||||
|
AC_DEFINE(HAVE_STRNLEN, 1, [Defines if strnlen is available on your system]))
|
||||||
|
AC_CHECK_FUNC(strndup,
|
||||||
|
AC_DEFINE(HAVE_STRNDUP, 1, [Defines if strndup is available on your system]))
|
||||||
#
|
#
|
||||||
# Solaris needs -lsocket -lnsl -lrt
|
# Solaris needs -lsocket -lnsl -lrt
|
||||||
AC_SEARCH_LIBS([bind], [socket])
|
AC_SEARCH_LIBS([bind], [socket])
|
||||||
|
@ -28,20 +28,21 @@
|
|||||||
/* Other systems have strncasecmp */
|
/* Other systems have strncasecmp */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* strndup() is a GNU extension. Other systems must fix it with elif's. */
|
/* strnlen() is a GNU extension. */
|
||||||
#if defined(__GNUC__) && !defined(__APPLE__)
|
#if HAVE_STRNLEN
|
||||||
extern char *strndup(__const char *__string, size_t __n);
|
extern size_t strnlen(const char *s, size_t maxlen);
|
||||||
#endif /* defined(__GNUC__) && !defined(__APPLE__) */
|
#else /* HAVE_STRNLEN */
|
||||||
|
|
||||||
#if defined(__GNUC__) && defined(__APPLE__)
|
|
||||||
static size_t strnlen(const char *s, size_t n)
|
static size_t strnlen(const char *s, size_t n)
|
||||||
{
|
{
|
||||||
const char *p = (const char *)memchr(s, 0, n);
|
const char *p = (const char *)memchr(s, 0, n);
|
||||||
return p ? p - s : n;
|
return p ? p - s : n;
|
||||||
}
|
}
|
||||||
#endif /* defined(__GNUC__) && defined(__APPLE__) */
|
#endif /* HAVE_STRNLEN */
|
||||||
|
|
||||||
#if (defined(__GNUC__) && defined(__APPLE__)) || defined(WIN32)
|
/* strndup() is a GNU extension. */
|
||||||
|
#if HAVE_STRNDUP && !defined(WIN32)
|
||||||
|
extern char *strndup(__const char *__string, size_t __n);
|
||||||
|
#else /* HAVE_STRNDUP && !defined(WIN32) */
|
||||||
static char *strndup(const char *__string, size_t __n)
|
static char *strndup(const char *__string, size_t __n)
|
||||||
{
|
{
|
||||||
size_t strsize = strnlen(__string, __n);
|
size_t strsize = strnlen(__string, __n);
|
||||||
@ -52,7 +53,7 @@
|
|||||||
|
|
||||||
return newstr;
|
return newstr;
|
||||||
}
|
}
|
||||||
#endif /* (defined(__GNUC__) && defined(__APPLE__)) || defined(WIN32) */
|
#endif /* HAVE_STRNDUP && !defined(WIN32) */
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Internal implementation of the class UpnpString.
|
* \brief Internal implementation of the class UpnpString.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user