cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STRLCPY $ac_have_decl
_ACEOF
-ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
-if test "x$ac_cv_have_decl_strnlen" = xyes; then :
- ac_have_decl=1
-else
- ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_STRNLEN $ac_have_decl
-_ACEOF
ac_fn_c_check_decl "$LINENO" "strsep" "ac_cv_have_decl_strsep" "$ac_includes_default"
if test "x$ac_cv_have_decl_strsep" = xyes; then :
ac_have_decl=1
fi
-ac_fn_c_check_func "$LINENO" "strnlen" "ac_cv_func_strnlen"
-if test "x$ac_cv_func_strnlen" = xyes; then :
- $as_echo "#define HAVE_STRNLEN 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" strnlen.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS strnlen.$ac_objext"
- ;;
-esac
-
-fi
-
ac_fn_c_check_func "$LINENO" "strsep" "ac_cv_func_strsep"
if test "x$ac_cv_func_strsep" = xyes; then :
$as_echo "#define HAVE_STRSEP 1" >>confdefs.h
]) # fi
AC_CHECK_DECLS(fdatasync, [], [], [#include <unistd.h>])
-AC_CHECK_DECLS([strlcat, strlcpy, strnlen, strsep, timingsafe_bcmp])
+AC_CHECK_DECLS([strlcat, strlcpy, strsep, timingsafe_bcmp])
# We can't use AC_CHECK_FUNCS to detect these functions, because it
# won't handle deployment target restrictions on macOS
mkdtemp
strlcat
strlcpy
- strnlen
strsep
timingsafe_bcmp
]))
['posix_fadvise', 'fcntl.h'],
['strlcat', 'string.h'],
['strlcpy', 'string.h'],
- ['strnlen', 'string.h'],
['strsep', 'string.h'],
['timingsafe_bcmp', 'string.h'],
]
['strerror_r', {'dependencies': [thread_dep]}],
['strlcat'],
['strlcpy'],
- ['strnlen'],
['strsep'],
['strsignal'],
['sync_file_range'],
don't. */
#undef HAVE_DECL_STRLCPY
-/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
- don't. */
-#undef HAVE_DECL_STRNLEN
-
/* Define to 1 if you have the declaration of `strsep', and to 0 if you don't.
*/
#undef HAVE_DECL_STRSEP
/* Define to 1 if you have the `strlcpy' function. */
#undef HAVE_STRLCPY
-/* Define to 1 if you have the `strnlen' function. */
-#undef HAVE_STRNLEN
-
/* Define to 1 if you have the `strsep' function. */
#undef HAVE_STRSEP
extern size_t strlcpy(char *dst, const char *src, size_t siz);
#endif
-#if !HAVE_DECL_STRNLEN
-extern size_t strnlen(const char *str, size_t maxlen);
-#endif
-
#if !HAVE_DECL_STRSEP
extern char *strsep(char **stringp, const char *delim);
#endif
['mkdtemp'],
['strlcat'],
['strlcpy'],
- ['strnlen'],
['strsep'],
['timingsafe_bcmp'],
]
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * strnlen.c
- * Fallback implementation of strnlen().
- *
- *
- * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * IDENTIFICATION
- * src/port/strnlen.c
- *
- *-------------------------------------------------------------------------
- */
-
-#include "c.h"
-
-/*
- * Implementation of posix' strnlen for systems where it's not available.
- *
- * Returns the number of characters before a null-byte in the string pointed
- * to by str, unless there's no null-byte before maxlen. In the latter case
- * maxlen is returned.
- */
-size_t
-strnlen(const char *str, size_t maxlen)
-{
- const char *p = str;
-
- while (maxlen-- > 0 && *p)
- p++;
- return p - str;
-}