1
0
mirror of https://github.com/libssh2/libssh2.git synced 2026-10-24 03:48:58 +03:00

build: assume standard snprintf()

Stop detecting standard `snprintf()`, and expect it to be available.

Except for the only known platform where it's missing: Visual Studio
2013 and older, where we keep using the existing local implementation.

`snprintf()` was already required to build examples and tests.

Closes #2326
This commit is contained in:
Viktor Szakats
2026-07-15 15:30:08 +02:00
parent 73164d34a1
commit be18d596c0
8 changed files with 6 additions and 25 deletions

View File

@@ -312,7 +312,6 @@ include(PickyWarnings)
# Keep this synced with src/libssh2_setup.h
if(WIN32)
if(MINGW)
set(HAVE_SNPRINTF 1)
set(HAVE_UNISTD_H 1)
set(HAVE_INTTYPES_H 1)
set(HAVE_SYS_TIME_H 1)
@@ -330,11 +329,6 @@ if(WIN32)
set(HAVE_STRTOLL 0)
set(HAVE_STRTOI64 1)
endif()
if(MSVC_VERSION GREATER_EQUAL 1900)
set(HAVE_SNPRINTF 1)
else()
set(HAVE_SNPRINTF 0)
endif()
endif()
set(HAVE_POLL 0)
set(HAVE_SELECT 1)
@@ -372,7 +366,6 @@ if(NOT HAVE_STRTOLL)
# Try _strtoi64() if strtoll() is not available
check_symbol_exists("_strtoi64" "stdlib.h" HAVE_STRTOI64)
endif()
check_symbol_exists("snprintf" "stdio.h" HAVE_SNPRINTF)
if(NOT WIN32)
check_symbol_exists("explicit_bzero" "string.h" HAVE_EXPLICIT_BZERO)
check_symbol_exists("explicit_memset" "string.h" HAVE_EXPLICIT_MEMSET)

View File

@@ -409,7 +409,7 @@ case $host in
;;
esac
AC_CHECK_FUNCS(gettimeofday select strtoll explicit_bzero explicit_memset memset_s snprintf)
AC_CHECK_FUNCS(gettimeofday select strtoll explicit_bzero explicit_memset memset_s)
dnl Check for select() into ws2_32 for Msys/Mingw
if test "$ac_cv_func_select" != "yes"; then

View File

@@ -120,10 +120,6 @@
/* Use OS/400 Qc3 */
#define LIBSSH2_OS400QC3
/* Use our platform-specific local implementation:
_libssh2_os400_snprintf */
#define HAVE_SNPRINTF 1
/* Define to the subdirectory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"

View File

@@ -49,7 +49,6 @@
#cmakedefine HAVE_GETTIMEOFDAY
#cmakedefine HAVE_STRTOLL
#cmakedefine HAVE_STRTOI64
#cmakedefine HAVE_SNPRINTF
#cmakedefine HAVE_EXPLICIT_BZERO
#cmakedefine HAVE_EXPLICIT_MEMSET
#cmakedefine HAVE_MEMSET_S

View File

@@ -138,12 +138,12 @@
#define SSH2_PRINTF(fmt, arg)
#endif
/* Use local implementation when not available */
#ifdef HAVE_SNPRINTF
#define ssh2_snprintf snprintf
#else
/* Use local implementation with <VS2015 */
#if defined(_MSC_VER) && _MSC_VER < 1900
int ssh2_snprintf(char *cp, size_t cp_max_len, const char *fmt, ...)
SSH2_PRINTF(3, 4);
#else
#define ssh2_snprintf snprintf
#endif
#ifndef SSH2_FALLTHROUGH

View File

@@ -25,7 +25,6 @@
#elif defined(_WIN32)
#define HAVE_SELECT
#define HAVE_SNPRINTF
#ifdef __MINGW32__
# define HAVE_UNISTD_H
@@ -40,9 +39,6 @@
# else
# define HAVE_STRTOI64
# endif
# if _MSC_VER < 1900
# undef HAVE_SNPRINTF
# endif
#endif
#endif /* HAVE_CONFIG_H */
@@ -91,8 +87,6 @@
/* we cannot access our internal snprintf() implementation in examples and
tests when linking to a shared libssh2. */
# if _MSC_VER < 1900
# undef HAVE_SNPRINTF
# define HAVE_SNPRINTF
# define snprintf _snprintf
# endif
# endif

View File

@@ -51,7 +51,7 @@
/* snprintf is not in pre-VS2015 CRTs and _snprintf dangerously incompatible.
We provide a safe wrapper for these environments */
#ifndef HAVE_SNPRINTF
#if defined(_MSC_VER) && _MSC_VER < 1900
#include <stdarg.h>
/* Want safe, 'n += snprintf(b + n ...)' like function. Returns number of chars

View File

@@ -29,7 +29,6 @@ typedef unsigned int socklen_t; /* missing in headers on VMS */
#define HAVE_ARPA_INET_H
#define HAVE_GETTIMEOFDAY 1
#define HAVE_SNPRINTF 1
#define POSIX_C_SOURCE