Skip to content

Commit

Permalink
Merge branch 'bugfixes'
Browse files Browse the repository at this point in the history
Conflicts:
	lib/framework/stdio_ext.cpp
	lib/framework/stdio_ext.h
  • Loading branch information
vexed committed Oct 26, 2014
2 parents 5991794 + a41b6e2 commit b0a5e0b
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 6 deletions.
6 changes: 5 additions & 1 deletion 3rdparty/quesoglc/GL/glc.h
Expand Up @@ -47,7 +47,11 @@
# define __WIN32__
#endif

#ifdef __WIN32__
// NOTE: For mingw-w64, we must define _GDI32_ otherwise we would be making WINGDIAPI DECLSPEC_IMPORT
// which we do not want (that is for shared libs, aka dlls). See wingdi.h to see where the check is.
// refs: http://sourceforge.net/p/mingw-w64/patches/41/
#if defined(__WIN32__) && !defined(WINGDIAPI)
# define _GDI32_
# include <windows.h>
#endif

Expand Down
7 changes: 5 additions & 2 deletions lib/exceptionhandler/exchndl.cpp
Expand Up @@ -81,8 +81,11 @@ DWORD GetModuleBase(DWORD dwAddress)
extern "C"
{
#include "include/demangle.h"
#include "include/coff/internal.h"
#include "include/libcoff.h"
// cross compiler does not like these...
#if !defined(WZ_CC_MINGW)
#include "include/coff/internal.h"
#include "include/libcoff.h"
#endif
}

// Read in the symbol table.
Expand Down
33 changes: 32 additions & 1 deletion lib/framework/stdio_ext.cpp
Expand Up @@ -24,7 +24,38 @@
#include <string.h>
#include <assert.h>

#if defined(WZ_OS_WIN)
#if defined(WZ_CC_MSVC)
int vslcatprintf(char* str, size_t size, const char* format, va_list ap)
{
size_t str_len;

if (str == NULL
|| size == 0)
{
return vsnprintf(NULL, 0, format, ap);
}

str_len = strlen(str);

assert(str_len < size);

return vsnprintf(&str[str_len], size - str_len, format, ap);
}


int slcatprintf(char* str, size_t size, const char* format, ...)
{
va_list ap;
int count;

va_start(ap, format);
count = vslcatprintf(str, size, format, ap);
va_end(ap);

return count;
}


int vasprintf(char** strp, const char* format, va_list ap)
{
int count;
Expand Down
21 changes: 20 additions & 1 deletion lib/framework/stdio_ext.h
Expand Up @@ -25,7 +25,26 @@
#include <stdio.h>
#include <stdarg.h>

#if defined(WZ_OS_WIN) || defined(DOXYGEN)
#if defined(WZ_CC_MSVC) || defined(DOXYGEN)
/** A variant on snprintf which appends its output string to the given string
* buffer, rather than to replace it.
* \param str the string to append to
* \param size the size of the buffer \c str expressed in bytes
* \param format the formatting string
* \param ap a variable arguments list of variables to use in the formatting
* string
* \return the amount of characters appended to the string
*/
extern int vslcatprintf(char* str, size_t size, const char* format, va_list ap);


/** A variant on snprintf which appends its output string to the given string
* The function's interface is similar to vslcatprintf(), so look at that
* function's description.
*/
extern int slcatprintf(char* str, size_t size, const char* format, ...) WZ_DECL_FORMAT(printf, 3, 4);


// These functions are GNU extensions; so make sure they are available on Windows also

/**
Expand Down
6 changes: 5 additions & 1 deletion lib/framework/wzglobal.h
Expand Up @@ -222,7 +222,7 @@

#elif defined(__GNUC__)
# define WZ_CC_GNU
# if defined(__MINGW32__)
# if defined(__MINGW32__) || defined(__MINGW64__)
# define WZ_CC_MINGW
# endif
# if defined(__INTEL_COMPILER)
Expand Down Expand Up @@ -532,6 +532,10 @@

#if defined(WZ_OS_WIN)
# if defined(WZ_CC_MINGW)
// NOTE: For mingw-w64, we must define _GDI32_ otherwise we would be making WINGDIAPI DECLSPEC_IMPORT
// which we do not want (that is for shared libs, aka dlls). See wingdi.h to see where the check is.
// refs: http://sourceforge.net/p/mingw-w64/patches/41/
# define _GDI32_
# include <unistd.h>
# include <sys/param.h>
# include <w32api.h>
Expand Down

0 comments on commit b0a5e0b

Please sign in to comment.