Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 39 additions & 14 deletions thirdparty/libtiff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ SET(TARGET_FILES

IF(UNIX)
SET(TARGET_FILES ${TARGET_FILES} tif_unix.c)
# Large file support
# This might not catch every possibility catered for by
# AC_SYS_LARGEFILE.
add_definitions(-D_FILE_OFFSET_BITS=64)
set(_FILE_OFFSET_BITS 64)
ELSE()
SET(TARGET_FILES ${TARGET_FILES} tif_win32.c)
ENDIF()
Expand All @@ -70,6 +75,7 @@ endif()
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckCSourceCompiles)

CHECK_INCLUDE_FILES("zlib.h" HAVE_ZLIB_H)
CHECK_INCLUDE_FILES("jpeglib.h" HAVE_JPEGLIB_H)
Expand Down Expand Up @@ -135,6 +141,19 @@ CHECK_FUNCTION_EXISTS(strtol HAVE_STRTOL)
CHECK_FUNCTION_EXISTS(strtoul HAVE_STRTOUL)
CHECK_FUNCTION_EXISTS(strtoull HAVE_STRTOULL)

# May be inlined, so check it compiles:
check_c_source_compiles("
#include <stdio.h>
int main(void) {
char buf[10];
snprintf(buf, 10, \"Test %d\", 1);
return 0;
}" HAVE_SNPRINTF)

if(NOT HAVE_SNPRINTF)
SET(TARGET_FILES ${TARGET_FILES} snprintf.c)
endif()

include(CheckTypeSize)

CHECK_TYPE_SIZE("signed int" SIZEOF_SIGNED_INT)
Expand Down Expand Up @@ -162,20 +181,23 @@ if(HAVE_STDINT_H)
if(NOT HAVE_SSIZE_T)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
set(TIFF_SSIZE_T int64_t)
set(TIFF_SSIZE_FORMAT "%lld")
set(TIFF_SIZE_FORMAT "%llu")
elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
set(TIFF_SSIZE_T int32_t)
set(TIFF_SSIZE_FORMAT "%d")
set(TIFF_SIZE_FORMAT "%u")
else()
message(FATAL_ERROR "unknown ssize_t")
endif()
else()
set(TIFF_SSIZE_T ssize_t)
endif()
set(TIFF_INT32_FORMAT "\"%d\"")
set(TIFF_UINT32_FORMAT "\"%u\"")
set(TIFF_INT64_FORMAT "\"%ld\"")
set(TIFF_UINT64_FORMAT "\"%lu\"")
set(TIFF_PTRDIFF_FORMAT "\"%ld\"")
set(TIFF_SSIZE_FORMAT "\"%ld\"")
set(TIFF_INT32_FORMAT "%d")
set(TIFF_UINT32_FORMAT "%u")
set(TIFF_INT64_FORMAT "%lld")
set(TIFF_UINT64_FORMAT "%llu")
set(TIFF_PTRDIFF_FORMAT "%ld")
else()
set(TIFF_INT8_T "signed __int8")
set(TIFF_INT16_T "signed __int16")
Expand All @@ -189,24 +211,27 @@ else()
if(NOT HAVE_SSIZE_T)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
set(TIFF_SSIZE_T "signed __int64")
set(TIFF_SSIZE_FORMAT "%lld")
set(TIFF_SIZE_FORMAT "%llu")
elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
set(TIFF_SSIZE_T "signed __int32")
set(TIFF_SSIZE_FORMAT "%d")
set(TIFF_SIZE_FORMAT "%u")
else()
message(FATAL_ERROR "unknown ssize_t")
endif()
else()
set(TIFF_SSIZE_T ssize_t)
endif()
set(TIFF_INT32_FORMAT "\"%d\"")
set(TIFF_UINT32_FORMAT "\"%u\"")
set(TIFF_INT64_FORMAT "\"%ld\"")
set(TIFF_UINT64_FORMAT "\"%lu\"")
set(TIFF_PTRDIFF_FORMAT "\"%ld\"")
set(TIFF_SSIZE_FORMAT "\"%ld\"")
set(TIFF_INT32_FORMAT "%d")
set(TIFF_UINT32_FORMAT "%u")
set(TIFF_INT64_FORMAT "%lld")
set(TIFF_UINT64_FORMAT "%llu")
set(TIFF_PTRDIFF_FORMAT "%ld")
endif()

#
set(VERSION "\"4.0.1\"")
set(VERSION "\"4.0.6\"")
set(PACKAGE_VERSION ${VERSION})
set(PACKAGE "\"tiff\"")

Expand All @@ -232,7 +257,7 @@ FOREACH(KEYWORD "inline" "__inline__" "__inline")
COMPILE_DEFINITIONS "-Dinline=${KEYWORD}")
IF(C_HAS_${KEYWORD})
SET(C_INLINE TRUE)
SET(INLINE "${KEYWORD}")
SET(INLINE_KEYWORD "${KEYWORD}")
ENDIF(C_HAS_${KEYWORD})
ENDIF(NOT DEFINED C_INLINE)
ENDFOREACH(KEYWORD)
Expand Down
60 changes: 60 additions & 0 deletions thirdparty/libtiff/libport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* $Id: libport.h,v 1.5 2015-08-19 02:31:04 bfriesen Exp $ */

/*
* Copyright (c) 2009 Frank Warmerdam
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that (i) the above copyright notices and this permission notice appear in
* all copies of the software and related documentation, and (ii) the names of
* Sam Leffler and Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written
* permission of Sam Leffler and Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/

#ifndef _LIBPORT_
#define _LIBPORT_

int getopt(int argc, char * const argv[], const char *optstring);
extern char *optarg;
extern int opterr;
extern int optind;
extern int optopt;

int strcasecmp(const char *s1, const char *s2);

#ifndef HAVE_GETOPT
# define HAVE_GETOPT 1
#endif

#if 0
unsigned long strtoul(const char *nptr, char **endptr, int base);
#endif

#if 0
void *
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_ */
38 changes: 38 additions & 0 deletions thirdparty/libtiff/snprintf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* 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)
count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
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
5 changes: 2 additions & 3 deletions thirdparty/libtiff/tif_codec.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: tif_codec.c,v 1.16 2013-05-02 14:44:29 tgl Exp $ */
/* $Id: tif_codec.c,v 1.17 2015-08-19 02:31:04 bfriesen Exp $ */

/*
* Copyright (c) 1988-1997 Sam Leffler
Expand Down Expand Up @@ -108,8 +108,7 @@ _notConfigured(TIFF* tif)
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
char compression_code[20];

snprintf(compression_code, sizeof(compression_code), "%d",
tif->tif_dir.td_compression );
sprintf(compression_code, "%d",tif->tif_dir.td_compression );
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"%s compression support is not configured",
c ? c->name : compression_code );
Expand Down
Loading