mirror of
https://github.com/postgres/postgres.git
synced 2026-01-26 09:41:40 +03:00
strnlen() is now required
Remove all configure checks and workarounds for strnlen() missing. It is required by POSIX 2008. Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/98ce805c-6103-421b-adc3-fcf8f3dddbe3%40eisentraut.org
This commit is contained in:
23
configure
vendored
23
configure
vendored
@@ -16079,16 +16079,6 @@ fi
|
||||
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
|
||||
@@ -16268,19 +16258,6 @@ esac
|
||||
|
||||
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
|
||||
|
||||
@@ -1823,7 +1823,7 @@ AC_CHECK_DECLS(posix_fadvise, [], [], [#include <fcntl.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
|
||||
@@ -1844,7 +1844,6 @@ AC_REPLACE_FUNCS(m4_normalize([
|
||||
mkdtemp
|
||||
strlcat
|
||||
strlcpy
|
||||
strnlen
|
||||
strsep
|
||||
timingsafe_bcmp
|
||||
]))
|
||||
|
||||
@@ -2666,7 +2666,6 @@ decl_checks = [
|
||||
['posix_fadvise', 'fcntl.h'],
|
||||
['strlcat', 'string.h'],
|
||||
['strlcpy', 'string.h'],
|
||||
['strnlen', 'string.h'],
|
||||
['strsep', 'string.h'],
|
||||
['timingsafe_bcmp', 'string.h'],
|
||||
]
|
||||
@@ -2914,7 +2913,6 @@ func_checks = [
|
||||
['strerror_r', {'dependencies': [thread_dep]}],
|
||||
['strlcat'],
|
||||
['strlcpy'],
|
||||
['strnlen'],
|
||||
['strsep'],
|
||||
['strsignal'],
|
||||
['sync_file_range'],
|
||||
|
||||
@@ -108,10 +108,6 @@
|
||||
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
|
||||
@@ -395,9 +391,6 @@
|
||||
/* 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
|
||||
|
||||
|
||||
@@ -476,10 +476,6 @@ extern size_t strlcat(char *dst, const char *src, size_t siz);
|
||||
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
|
||||
|
||||
@@ -72,7 +72,6 @@ replace_funcs_neg = [
|
||||
['mkdtemp'],
|
||||
['strlcat'],
|
||||
['strlcpy'],
|
||||
['strnlen'],
|
||||
['strsep'],
|
||||
['timingsafe_bcmp'],
|
||||
]
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
Reference in New Issue
Block a user