summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/libtiff/port
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/libtiff/port')
-rw-r--r--src/3rdparty/libtiff/port/libport.h11
-rw-r--r--src/3rdparty/libtiff/port/snprintf.c38
-rw-r--r--src/3rdparty/libtiff/port/strcasecmp.c6
3 files changed, 51 insertions, 4 deletions
diff --git a/src/3rdparty/libtiff/port/libport.h b/src/3rdparty/libtiff/port/libport.h
index 802f478..d9b0421 100644
--- a/src/3rdparty/libtiff/port/libport.h
+++ b/src/3rdparty/libtiff/port/libport.h
@@ -1,4 +1,4 @@
-/* $Id: libport.h,v 1.2 2009-11-02 14:44:13 bfriesen Exp $ */
+/* $Id: libport.h,v 1.5 2015-08-19 02:31:04 bfriesen Exp $ */
/*
* Copyright (c) 2009 Frank Warmerdam
@@ -48,4 +48,13 @@ 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_ */
diff --git a/src/3rdparty/libtiff/port/snprintf.c b/src/3rdparty/libtiff/port/snprintf.c
new file mode 100644
index 0000000..1c4ac08
--- /dev/null
+++ b/src/3rdparty/libtiff/port/snprintf.c
@@ -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
diff --git a/src/3rdparty/libtiff/port/strcasecmp.c b/src/3rdparty/libtiff/port/strcasecmp.c
index 1ff4312..de7e423 100644
--- a/src/3rdparty/libtiff/port/strcasecmp.c
+++ b/src/3rdparty/libtiff/port/strcasecmp.c
@@ -1,4 +1,4 @@
-/* $Id: strcasecmp.c,v 1.3 2009-01-22 20:53:07 fwarmerdam Exp $ */
+/* $Id: strcasecmp.c,v 1.4 2015-06-21 01:09:09 bfriesen Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -44,8 +44,8 @@ strcasecmp(const char *s1, const char *s2)
const unsigned char *us1 = (const unsigned char *)s1,
*us2 = (const unsigned char *)s2;
- while (tolower(*us1) == tolower(*us2++))
+ while (tolower((int) *us1) == tolower((int) *us2++))
if (*us1++ == '\0')
return (0);
- return (tolower(*us1) - tolower(*--us2));
+ return (tolower((int) *us1) - tolower((int) *--us2));
}