From 893b3f2269f9b1590245f2e697be3af76b2954cf Mon Sep 17 00:00:00 2001 From: Stefan Vigerske Date: Wed, 11 Dec 2024 16:48:38 +0100 Subject: [PATCH] simplify Snprintf implementation - assume vsnprintf (or _vsnprintf with old MSVS) to be present, instead of checking with configure; configure check for (_)vsnprintf doesn't seem to work with current MSVS (maybe these are macros) - remove old code for SunOS that wasn't in IpJournalist anyway --- configure | 94 ++---------------------------------------- configure.ac | 7 ++-- doc/Doxyfile.in | 2 - src/Common/IpUtils.cpp | 45 +------------------- src/Common/config.h.in | 6 --- 5 files changed, 9 insertions(+), 145 deletions(-) diff --git a/configure b/configure index 4e1dc34f4..b2586b2b1 100755 --- a/configure +++ b/configure @@ -2583,78 +2583,6 @@ printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_check_decl - -# ac_fn_cxx_check_func LINENO FUNC VAR -# ------------------------------------ -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_cxx_check_func () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -printf %s "checking for $2... " >&6; } -if eval test \${$3+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case declares $2. - For example, HP-UX 11i declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (void); below. */ - -#include -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (void); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -#ifdef F77_DUMMY_MAIN - -# ifdef __cplusplus - extern "C" -# endif - int F77_DUMMY_MAIN() { return 1; } - -#endif -int -main (void) -{ -return $2 (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO" -then : - eval "$3=yes" -else case e in #( - e) eval "$3=no" ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext ;; -esac -fi -eval ac_res=\$$3 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_cxx_check_func ac_configure_args_raw= for ac_arg do @@ -28217,9 +28145,9 @@ printf "%s\n" "#define IPOPT_C_FINITE $COIN_C_FINITE" >>confdefs.h fi -######################### -# va_copy and vsnprintf # -######################### +########### +# va_copy # +########### ac_fn_check_decl "$LINENO" "va_copy" "ac_cv_have_decl_va_copy" "#include " "$ac_cxx_undeclared_builtin_options" "CXXFLAGS" @@ -28230,20 +28158,6 @@ printf "%s\n" "#define IPOPT_HAS_VA_COPY 1" >>confdefs.h fi - for ac_func in vsnprintf _vsnprintf -do : - as_ac_var=`printf "%s\n" "ac_cv_func_$ac_func" | sed "$as_sed_sh"` -ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes" -then : - cat >>confdefs.h <<_ACEOF -#define `printf "%s\n" "HAVE_$ac_func" | sed "$as_sed_cpp"` 1 -_ACEOF - break -fi - -done - ########################### # Random number generator # ########################### @@ -28489,7 +28403,7 @@ else case e in #( JAVA_TEST=Test.java CLASS_TEST=Test.class cat << \EOF > $JAVA_TEST -/* #line 28492 "configure" */ +/* #line 28406 "configure" */ public class Test { } EOF diff --git a/configure.ac b/configure.ac index 0f3cd96c2..b689c9ab6 100644 --- a/configure.ac +++ b/configure.ac @@ -299,13 +299,12 @@ AC_LANG_PUSH(C++) AC_COIN_CHECK_ISFINITE -######################### -# va_copy and vsnprintf # -######################### +########### +# va_copy # +########### AC_CHECK_DECL([va_copy],[AC_DEFINE([IPOPT_HAS_VA_COPY],[1], [Define to 1 if va_copy is available])],,[#include ]) -AC_CHECK_FUNCS([vsnprintf _vsnprintf],[break]) ########################### # Random number generator # diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index 2e629a8a6..372369db1 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -2353,9 +2353,7 @@ PREDEFINED = IPOPT_HAS_ASL \ HAVE_DLFCN_H \ HAVE_DRAND48 \ HAVE_PARDISO \ - HAVE_SNPRINTF \ HAVE_VA_COPY \ - HAVE_VSNPRINTF \ HAVE_WSMP \ F77_FUNC(x)=x \ IPOPT_LAPACK_FUNC(x)=x \ diff --git a/src/Common/IpUtils.cpp b/src/Common/IpUtils.cpp index 8ba03c7b7..5052a4579 100644 --- a/src/Common/IpUtils.cpp +++ b/src/Common/IpUtils.cpp @@ -19,12 +19,8 @@ #include #include -// The special treatment of vsnprintf on SUN has been suggested by Lou Hafer 2010/07/04 -#if defined(HAVE_VSNPRINTF) && defined(__SUNPRO_CC) -namespace std -{ -#include -} +#if defined(_MSC_VER) && _MSC_VER < 1900 +#define vsnprintf _vsnprintf #endif // The following code has been copied from CoinUtils' CoinTime @@ -313,47 +309,10 @@ int Snprintf( ... ) { -#if defined(HAVE_VSNPRINTF) && defined(__SUNPRO_CC) - std::va_list ap; -#else va_list ap; -#endif va_start(ap, format); int ret; -#ifdef IPOPT_HAS_VA_COPY - va_list apcopy; - va_copy(apcopy, ap); -# ifdef HAVE_VSNPRINTF -# ifdef __SUNPRO_CC - ret = std::vsnprintf(str, size, format, apcopy); -# else - ret = vsnprintf(str, size, format, apcopy); -# endif -# else -# ifdef HAVE__VSNPRINTF - ret = _vsnprintf(str, size, format, apcopy); -# else - ret = vsprintf(str, format, apcopy); - (void) size; -# endif -# endif - va_end(apcopy); -#else -# ifdef HAVE_VSNPRINTF -# ifdef __SUNPRO_CC - ret = std::vsnprintf(str, size, format, ap); -# else ret = vsnprintf(str, size, format, ap); -# endif -# else -# ifdef HAVE__VSNPRINTF - ret = _vsnprintf(str, size, format, ap); -# else - ret = vsprintf(str, format, ap); - (void) size; -# endif -# endif -#endif va_end(ap); return ret; } diff --git a/src/Common/config.h.in b/src/Common/config.h.in index 11239981a..d7963b41d 100644 --- a/src/Common/config.h.in +++ b/src/Common/config.h.in @@ -74,15 +74,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H -/* Define to 1 if you have the 'vsnprintf' function. */ -#undef HAVE_VSNPRINTF - /* Define to 1 if windows.h is available. */ #undef HAVE_WINDOWS_H -/* Define to 1 if you have the '_vsnprintf' function. */ -#undef HAVE__VSNPRINTF - /* Library Visibility Attribute */ #undef HSLLIB_EXPORT