Remove test for snprintf() from configure and elsewhere
This is needed to work around a build failure when this test fails, as it spuriously does when cross-compiling for MinGW using v10 API package, see https://sourceforge.net/p/mingw-w64/bugs/935/ for more details. Of course, the fact that the build fails if snprintf() is unavailable is actually a bug, but in practice this function is available everywhere by now, so simply stop testing for it. This mostly cherry picks ceff22ee (Use C99 snprintf, 2021-01-31), but keeps the test for MSVC versions without vsnprintf() for compatibility.
This commit is contained in:
parent
4610f67218
commit
af035310bd
@ -83,7 +83,7 @@ build_script:
|
||||
- 'if %compiler%==mingw-cmake cmake --build . --config %configuration% --target install'
|
||||
- 'if %compiler%==vc14-cmake cmake --build . --config %configuration% --target install'
|
||||
- 'if %compiler%==vc9-cmake cmake --build . --config %configuration% --target install'
|
||||
- 'if %compiler%==vc14-nmake nmake /f Makefile.vc EXTRAFLAGS=/DHAVE_SNPRINTF=1'
|
||||
- 'if %compiler%==vc14-nmake nmake /f Makefile.vc'
|
||||
- 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%'
|
||||
- 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%\bin'
|
||||
- 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%\lib'
|
||||
|
@ -376,7 +376,6 @@ endif()
|
||||
|
||||
check_symbol_exists(mmap "sys/mman.h" HAVE_MMAP)
|
||||
check_symbol_exists(setmode "unistd.h" HAVE_SETMODE)
|
||||
check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
|
||||
check_symbol_exists(strcasecmp "strings.h" HAVE_STRCASECMP)
|
||||
check_symbol_exists(strtol "stdlib.h" HAVE_STRTOL)
|
||||
check_symbol_exists(strtoll "stdlib.h" HAVE_STRTOLL)
|
||||
@ -385,10 +384,6 @@ check_symbol_exists(strtoull "stdlib.h" HAVE_STRTOULL)
|
||||
check_symbol_exists(getopt "unistd.h;stdio.h" HAVE_GETOPT)
|
||||
check_symbol_exists(lfind "search.h" HAVE_LFIND)
|
||||
|
||||
if(NOT HAVE_SNPRINTF)
|
||||
add_definitions(-DNEED_LIBPORT)
|
||||
endif()
|
||||
|
||||
# CPU bit order
|
||||
set(HOST_FILLORDER FILLORDER_MSB2LSB)
|
||||
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i.*86.*" OR
|
||||
|
16
configure
vendored
16
configure
vendored
@ -18158,7 +18158,7 @@ cat >>confdefs.h <<_ACEOF
|
||||
_ACEOF
|
||||
|
||||
|
||||
for ac_func in mmap setmode snprintf
|
||||
for ac_func in mmap setmode
|
||||
do :
|
||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
||||
@ -18185,20 +18185,6 @@ esac
|
||||
fi
|
||||
|
||||
|
||||
ac_fn_c_check_func "$LINENO" "snprintf" "ac_cv_func_snprintf"
|
||||
if test "x$ac_cv_func_snprintf" = xyes; then :
|
||||
$as_echo "#define HAVE_SNPRINTF 1" >>confdefs.h
|
||||
|
||||
else
|
||||
case " $LIBOBJS " in
|
||||
*" snprintf.$ac_objext "* ) ;;
|
||||
*) LIBOBJS="$LIBOBJS snprintf.$ac_objext"
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
|
||||
ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp"
|
||||
if test "x$ac_cv_func_strcasecmp" = xyes; then :
|
||||
$as_echo "#define HAVE_STRCASECMP 1" >>confdefs.h
|
||||
|
@ -407,11 +407,10 @@ AC_DEFINE_UNQUOTED(TIFF_PTRDIFF_T,$PTRDIFF_T,[Pointer difference type])
|
||||
AC_DEFINE_UNQUOTED(TIFF_PTRDIFF_FORMAT,$PTRDIFF_FORMAT,[Pointer difference type formatter])
|
||||
|
||||
dnl Checks for library functions.
|
||||
AC_CHECK_FUNCS([mmap setmode snprintf])
|
||||
AC_CHECK_FUNCS([mmap setmode])
|
||||
|
||||
dnl Will use local replacements for unavailable functions
|
||||
AC_REPLACE_FUNCS(getopt)
|
||||
AC_REPLACE_FUNCS(snprintf)
|
||||
AC_REPLACE_FUNCS(strcasecmp)
|
||||
AC_REPLACE_FUNCS(strtol)
|
||||
AC_REPLACE_FUNCS(strtoll)
|
||||
|
@ -68,9 +68,6 @@
|
||||
/* Define to 1 if you have the `setmode' function. */
|
||||
#cmakedefine HAVE_SETMODE 1
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#cmakedefine HAVE_SNPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#cmakedefine HAVE_STDINT_H 1
|
||||
|
||||
|
@ -92,9 +92,6 @@
|
||||
/* Define to 1 if you have the `setmode' function. */
|
||||
#undef HAVE_SETMODE
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#undef HAVE_SNPRINTF
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
|
@ -55,12 +55,6 @@ extern void *lfind(const void *, const void *, size_t *, size_t,
|
||||
int (*)(const void *, const void *));
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SNPRINTF) && !defined(HAVE__SNPRINTF)
|
||||
#undef snprintf
|
||||
#define snprintf _TIFF_snprintf_f
|
||||
extern int snprintf(char* str, size_t size, const char* format, ...);
|
||||
#endif
|
||||
|
||||
#include "tiffio.h"
|
||||
|
||||
#include "tif_dir.h"
|
||||
|
@ -41,9 +41,6 @@ endif()
|
||||
if(NOT HAVE_LFIND)
|
||||
list(APPEND port_USED_FILES lfind.c)
|
||||
endif()
|
||||
if(MSVC AND NOT HAVE_SNPRINTF)
|
||||
list(APPEND port_USED_FILES snprintf.c)
|
||||
endif()
|
||||
if(NOT HAVE_STRCASECMP)
|
||||
list(APPEND port_USED_FILES strcasecmp.c)
|
||||
endif()
|
||||
|
@ -27,7 +27,6 @@ EXTRA_DIST = \
|
||||
CMakeLists.txt \
|
||||
Makefile.vc \
|
||||
libport.h \
|
||||
snprintf.c \
|
||||
_strtol.h \
|
||||
_strtoul.h
|
||||
|
||||
|
@ -151,10 +151,9 @@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/libtiff
|
||||
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
|
||||
am__maybe_remake_depfiles = depfiles
|
||||
am__depfiles_remade = $(DEPDIR)/getopt.Plo $(DEPDIR)/lfind.Plo \
|
||||
$(DEPDIR)/snprintf.Plo $(DEPDIR)/strcasecmp.Plo \
|
||||
$(DEPDIR)/strtol.Plo $(DEPDIR)/strtoll.Plo \
|
||||
$(DEPDIR)/strtoul.Plo $(DEPDIR)/strtoull.Plo \
|
||||
./$(DEPDIR)/dummy.Plo
|
||||
$(DEPDIR)/strcasecmp.Plo $(DEPDIR)/strtol.Plo \
|
||||
$(DEPDIR)/strtoll.Plo $(DEPDIR)/strtoul.Plo \
|
||||
$(DEPDIR)/strtoull.Plo ./$(DEPDIR)/dummy.Plo
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
@ -201,8 +200,8 @@ am__define_uniq_tagged_files = \
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp \
|
||||
getopt.c lfind.c snprintf.c strcasecmp.c strtol.c strtoll.c \
|
||||
strtoul.c strtoull.c
|
||||
getopt.c lfind.c strcasecmp.c strtol.c strtoll.c strtoul.c \
|
||||
strtoull.c
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
@ -420,7 +419,6 @@ distclean-compile:
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getopt.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/lfind.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/snprintf.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strcasecmp.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strtol.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strtoll.Plo@am__quote@ # am--include-marker
|
||||
@ -588,7 +586,6 @@ clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
|
||||
distclean: distclean-am
|
||||
-rm -f $(DEPDIR)/getopt.Plo
|
||||
-rm -f $(DEPDIR)/lfind.Plo
|
||||
-rm -f $(DEPDIR)/snprintf.Plo
|
||||
-rm -f $(DEPDIR)/strcasecmp.Plo
|
||||
-rm -f $(DEPDIR)/strtol.Plo
|
||||
-rm -f $(DEPDIR)/strtoll.Plo
|
||||
@ -642,7 +639,6 @@ installcheck-am:
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f $(DEPDIR)/getopt.Plo
|
||||
-rm -f $(DEPDIR)/lfind.Plo
|
||||
-rm -f $(DEPDIR)/snprintf.Plo
|
||||
-rm -f $(DEPDIR)/strcasecmp.Plo
|
||||
-rm -f $(DEPDIR)/strtol.Plo
|
||||
-rm -f $(DEPDIR)/strtoll.Plo
|
||||
|
@ -64,7 +64,6 @@ STRTOULL_OBJ = strtoull.obj
|
||||
INCL = -I..\libtiff
|
||||
|
||||
OBJ = \
|
||||
snprintf.obj \
|
||||
strcasecmp.obj \
|
||||
$(STRTOL_OBJ) \
|
||||
$(STRTOUL_OBJ) \
|
||||
|
@ -59,13 +59,4 @@ lfind(const void *key, const void *base, size_t *nmemb, size_t size,
|
||||
int(*compar)(const void *, const void *));
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SNPRINTF)
|
||||
#undef vsnprintf
|
||||
#define vsnprintf _TIFF_vsnprintf_f
|
||||
|
||||
#undef snprintf
|
||||
#define snprintf _TIFF_snprintf_f
|
||||
int snprintf(char* str, size_t size, const char* format, ...);
|
||||
#endif
|
||||
|
||||
#endif /* ndef _LIBPORT_ */
|
||||
|
@ -1,42 +0,0 @@
|
||||
/**
|
||||
* Workaround for lack of snprintf(3) in Visual Studio. See
|
||||
* http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010/8712996#8712996
|
||||
* It's a trivial wrapper around the builtin _vsnprintf_s and
|
||||
* _vscprintf functions.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "libport.h"
|
||||
|
||||
int _TIFF_vsnprintf_f(char* str, size_t size, const char* format, va_list ap)
|
||||
{
|
||||
int count = -1;
|
||||
|
||||
if (size != 0)
|
||||
#if _MSC_VER <= 1310
|
||||
count = _vsnprintf(str, size, format, ap);
|
||||
#else
|
||||
count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
|
||||
#endif
|
||||
if (count == -1)
|
||||
count = _vscprintf(format, ap);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int _TIFF_snprintf_f(char* str, size_t size, const char* format, ...)
|
||||
{
|
||||
int count;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
count = vsnprintf(str, size, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif // _MSC_VER
|
Loading…
Reference in New Issue
Block a user