diff options
author | Even Rouault <even.rouault@spatialys.com> | 2021-02-03 22:29:32 +0000 |
---|---|---|
committer | Even Rouault <even.rouault@spatialys.com> | 2021-02-03 22:29:32 +0000 |
commit | 4b48baef4c9c36e1c41cee326ce6f22437f630fb (patch) | |
tree | 86ccb70c07b78b595bb4a73805ce0712681d9197 | |
parent | a3a43d5324680e2f64a8969c78a5bdb540654c1a (diff) | |
parent | ceff22ee3b78ebec3ff0081c7ee178b44b511b45 (diff) | |
download | libtiff-git-4b48baef4c9c36e1c41cee326ce6f22437f630fb.tar.gz |
Merge branch 'c99-snprintf' into 'master'
Use C99 snprintf
See merge request libtiff/libtiff!217
-rw-r--r-- | .appveyor.yml | 2 | ||||
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | libtiff/tif_config.h.cmake.in | 3 | ||||
-rw-r--r-- | libtiff/tif_config.vc.h | 14 | ||||
-rw-r--r-- | libtiff/tif_win32.c | 4 | ||||
-rw-r--r-- | libtiff/tiffiop.h | 6 | ||||
-rwxr-xr-x | port/CMakeLists.txt | 3 | ||||
-rw-r--r-- | port/Makefile.am | 3 | ||||
-rw-r--r-- | port/Makefile.vc | 1 | ||||
-rw-r--r-- | port/libport.h | 9 | ||||
-rw-r--r-- | port/snprintf.c | 42 |
12 files changed, 3 insertions, 92 deletions
diff --git a/.appveyor.yml b/.appveyor.yml index 28defae6..4b5e53f3 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -85,7 +85,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' diff --git a/CMakeLists.txt b/CMakeLists.txt index d8fb7ed8..01f2571b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,13 +275,8 @@ report_values(TIFF_SSIZE_T) 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(getopt "unistd.h;stdio.h" HAVE_GETOPT) -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 diff --git a/configure.ac b/configure.ac index 7acc4fc7..0e09fbc3 100644 --- a/configure.ac +++ b/configure.ac @@ -237,11 +237,10 @@ AC_MSG_RESULT($SSIZE_T) AC_DEFINE_UNQUOTED(TIFF_SSIZE_T,$SSIZE_T,[Signed size type]) 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) dnl --------------------------------------------------------------------------- dnl Check the native cpu bit order. diff --git a/libtiff/tif_config.h.cmake.in b/libtiff/tif_config.h.cmake.in index 6e824a5b..2b3d8d43 100644 --- a/libtiff/tif_config.h.cmake.in +++ b/libtiff/tif_config.h.cmake.in @@ -56,9 +56,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 diff --git a/libtiff/tif_config.vc.h b/libtiff/tif_config.vc.h index 1479aa67..fafc422e 100644 --- a/libtiff/tif_config.vc.h +++ b/libtiff/tif_config.vc.h @@ -59,20 +59,6 @@ /* Set the native cpu bit order */ #define HOST_FILLORDER FILLORDER_LSB2MSB -/* - Please see associated settings in "nmake.opt" which configure porting - settings. It should not be necessary to edit the following pre-processor - logic. -*/ -#if defined(_MSC_VER) -/* Visual Studio 2015 / VC 14 / MSVC 19.00 finally has snprintf() */ -# if _MSC_VER < 1900 /* Visual C++ 2015 */ -# define snprintf _snprintf -# else -# define HAVE_SNPRINTF 1 -# endif -#endif - /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ /* #undef WORDS_BIGENDIAN */ diff --git a/libtiff/tif_win32.c b/libtiff/tif_win32.c index 073f0ade..c6ca1519 100644 --- a/libtiff/tif_win32.c +++ b/libtiff/tif_win32.c @@ -404,10 +404,6 @@ _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c) #ifndef _WIN32_WCE -#if (_MSC_VER < 1500) -# define vsnprintf _vsnprintf -#endif - static void Win32WarningHandler(const char* module, const char* fmt, va_list ap) { diff --git a/libtiff/tiffiop.h b/libtiff/tiffiop.h index 167bd14c..a4ef92ea 100644 --- a/libtiff/tiffiop.h +++ b/libtiff/tiffiop.h @@ -46,12 +46,6 @@ # define assert(x) #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" diff --git a/port/CMakeLists.txt b/port/CMakeLists.txt index 5073a70e..b04ecc6f 100755 --- a/port/CMakeLists.txt +++ b/port/CMakeLists.txt @@ -33,9 +33,6 @@ set(port_USED_FILES ${port_SOURCES} ${port_HEADERS}) if(NOT HAVE_GETOPT) list(APPEND port_USED_FILES getopt.c) endif() -if(MSVC AND NOT HAVE_SNPRINTF) - list(APPEND port_USED_FILES snprintf.c) -endif() add_library(port STATIC ${port_USED_FILES}) diff --git a/port/Makefile.am b/port/Makefile.am index 4d6e11d0..ea17898b 100644 --- a/port/Makefile.am +++ b/port/Makefile.am @@ -26,8 +26,7 @@ EXTRA_DIST = \ CMakeLists.txt \ Makefile.vc \ - libport.h \ - snprintf.c + libport.h noinst_LTLIBRARIES = libport.la libport_la_SOURCES = dummy.c libport.h diff --git a/port/Makefile.vc b/port/Makefile.vc index 880079d5..23bf06bf 100644 --- a/port/Makefile.vc +++ b/port/Makefile.vc @@ -30,7 +30,6 @@ INCL = -I..\libtiff OBJ = \ - snprintf.obj \ getopt.obj all: libport.lib diff --git a/port/libport.h b/port/libport.h index 7921c9e1..58a5e912 100644 --- a/port/libport.h +++ b/port/libport.h @@ -38,13 +38,4 @@ extern int optopt; # define HAVE_GETOPT 1 #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_ */ diff --git a/port/snprintf.c b/port/snprintf.c deleted file mode 100644 index 3542ab75..00000000 --- a/port/snprintf.c +++ /dev/null @@ -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 |