comparison extern/jansson/snprintf.patch @ 122:2aecbd638b1c

Irccd: add an upstream patch to fix jansson on VS, #425
author David Demelier <markand@malikania.fr>
date Wed, 04 May 2016 13:38:02 +0200
parents
children 254bbc0f13b5
comparison
equal deleted inserted replaced
121:12d8f2d20c77 122:2aecbd638b1c
1 diff --git a/cmake/jansson_private_config.h.cmake b/cmake/jansson_private_config.h.cmake
2 index ee1078f..ac7318f 100644
3 --- a/cmake/jansson_private_config.h.cmake
4 +++ b/cmake/jansson_private_config.h.cmake
5 @@ -49,6 +49,20 @@
6
7 #cmakedefine HAVE_SNPRINTF 1
8
9 +/* snprintf should not be defined as macro with MSC_VER >= 1900 */
10 +#if defined(_WIN32) || defined(WIN32)
11 +# if defined(_MSC_VER) /* MS compiller */
12 +# if (_MSC_VER < 1900) /* snprintf not introduced */
13 +# if !defined(snprintf)
14 +# define snprintf _snprintf
15 +# define HAVE_SNPRINTF 1 /* snprintf defined manually */
16 +# endif
17 +# else
18 +# define HAVE_SNPRINTF 1 /* snprintf available via sdk */
19 +# endif
20 +# endif
21 +#endif
22 +
23 #ifndef HAVE_SNPRINTF
24 # define snprintf @JSON_SNPRINTF@
25 #endif
26 diff --git a/src/jansson_private.h b/src/jansson_private.h
27 index e100726..ccb3a57 100644
28 --- a/src/jansson_private.h
29 +++ b/src/jansson_private.h
30 @@ -90,10 +90,20 @@ char *jsonp_strndup(const char *str, size_t length);
31 char *jsonp_strdup(const char *str);
32 char *jsonp_strndup(const char *str, size_t len);
33
34 +
35 /* Windows compatibility */
36 -#ifdef _WIN32
37 -#define snprintf _snprintf
38 -#define vsnprintf _vsnprintf
39 +#if defined(_WIN32) || defined(WIN32)
40 +# if defined(_MSC_VER) /* MS compiller */
41 +# if (_MSC_VER < 1900) && !defined(snprintf) /* snprintf not defined yet & not introduced */
42 +# define snprintf _snprintf
43 +# endif
44 +# if (_MSC_VER < 1500) && !defined(vsnprintf) /* vsnprintf not defined yet & not introduced */
45 +# define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
46 +# endif
47 +# else /* Other Windows compiller, old definition */
48 +# define snprintf _snprintf
49 +# define vsnprintf _vsnprintf
50 +# endif
51 #endif
52
53 #endif