libport: Add a replacement implementation for strnlen.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
acdbea2bee
commit
9d36aad457
|
@ -15747,6 +15747,7 @@ for ac_func in \
|
||||||
strdup \
|
strdup \
|
||||||
strerror \
|
strerror \
|
||||||
strncasecmp \
|
strncasecmp \
|
||||||
|
strnlen \
|
||||||
strtold \
|
strtold \
|
||||||
strtoll \
|
strtoll \
|
||||||
strtoull \
|
strtoull \
|
||||||
|
|
|
@ -2125,6 +2125,7 @@ AC_CHECK_FUNCS(\
|
||||||
strdup \
|
strdup \
|
||||||
strerror \
|
strerror \
|
||||||
strncasecmp \
|
strncasecmp \
|
||||||
|
strnlen \
|
||||||
strtold \
|
strtold \
|
||||||
strtoll \
|
strtoll \
|
||||||
strtoull \
|
strtoull \
|
||||||
|
|
|
@ -921,6 +921,9 @@
|
||||||
/* Define to 1 if you have the `strncasecmp' function. */
|
/* Define to 1 if you have the `strncasecmp' function. */
|
||||||
#undef HAVE_STRNCASECMP
|
#undef HAVE_STRNCASECMP
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strnlen' function. */
|
||||||
|
#undef HAVE_STRNLEN
|
||||||
|
|
||||||
/* Define to 1 if you have the <stropts.h> header file. */
|
/* Define to 1 if you have the <stropts.h> header file. */
|
||||||
#undef HAVE_STROPTS_H
|
#undef HAVE_STROPTS_H
|
||||||
|
|
||||||
|
|
|
@ -344,6 +344,10 @@ int strncasecmp(const char *str1, const char *str2, size_t n);
|
||||||
# endif
|
# endif
|
||||||
#endif /* !defined(HAVE_STRNCASECMP) */
|
#endif /* !defined(HAVE_STRNCASECMP) */
|
||||||
|
|
||||||
|
#ifndef HAVE_STRNLEN
|
||||||
|
size_t strnlen( const char *str, size_t maxlen );
|
||||||
|
#endif /* !defined(HAVE_STRNLEN) */
|
||||||
|
|
||||||
#ifndef HAVE_STRERROR
|
#ifndef HAVE_STRERROR
|
||||||
const char *strerror(int err);
|
const char *strerror(int err);
|
||||||
#endif /* !defined(HAVE_STRERROR) */
|
#endif /* !defined(HAVE_STRERROR) */
|
||||||
|
@ -538,6 +542,7 @@ extern __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compa
|
||||||
#define strcasecmp __WINE_NOT_PORTABLE(strcasecmp)
|
#define strcasecmp __WINE_NOT_PORTABLE(strcasecmp)
|
||||||
#define strerror __WINE_NOT_PORTABLE(strerror)
|
#define strerror __WINE_NOT_PORTABLE(strerror)
|
||||||
#define strncasecmp __WINE_NOT_PORTABLE(strncasecmp)
|
#define strncasecmp __WINE_NOT_PORTABLE(strncasecmp)
|
||||||
|
#define strnlen __WINE_NOT_PORTABLE(strnlen)
|
||||||
#define usleep __WINE_NOT_PORTABLE(usleep)
|
#define usleep __WINE_NOT_PORTABLE(usleep)
|
||||||
|
|
||||||
#endif /* NO_LIBWINE_PORT */
|
#endif /* NO_LIBWINE_PORT */
|
||||||
|
|
|
@ -102,6 +102,7 @@ C_SRCS = \
|
||||||
strcasecmp.c \
|
strcasecmp.c \
|
||||||
strerror.c \
|
strerror.c \
|
||||||
strncasecmp.c \
|
strncasecmp.c \
|
||||||
|
strnlen.c \
|
||||||
symlink.c \
|
symlink.c \
|
||||||
usleep.c \
|
usleep.c \
|
||||||
utf8.c \
|
utf8.c \
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* strnlen function
|
||||||
|
*
|
||||||
|
* Copyright 2017 Alexandre Julliard
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "wine/port.h"
|
||||||
|
|
||||||
|
#ifndef HAVE_STRNLEN
|
||||||
|
size_t strnlen( const char *str, size_t maxlen )
|
||||||
|
{
|
||||||
|
const char *ptr = memchr( str, 0, maxlen );
|
||||||
|
if (!ptr) return maxlen;
|
||||||
|
return ptr - str;
|
||||||
|
}
|
||||||
|
#endif /* HAVE_STRNLEN */
|
Loading…
Reference in New Issue