Changeset 4822


Ignore:
Timestamp:
06/17/12 14:36:30 (11 months ago)
Author:
sam
Message:

win32: define a custom sprintf_s() weak symbol. The VS2010 runtime does not
provide the deprecated snprintf(). The mingw32 runtime does not provide the
MS-specific sprintf_s(). Mingw-w64 copes with both. So we switch to sprintf_s
but also provide it as a weak symbol so that mingw32 does not complain.

Location:
libcaca/trunk/caca
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/caca.h

    r4818 r4822  
    688688#   else 
    689689#       define CACA_ALIAS(x) 
     690#   endif 
     691 
     692#   if defined __GNUC__ && __GNUC__ > 3 
     693#       define CACA_WEAK __attribute__ ((weak)) 
     694#   else 
     695#       define CACA_WEAK 
    690696#   endif 
    691697 
  • libcaca/trunk/caca/canvas.c

    r4369 r4822  
    342342 *  (inclusive). 
    343343 */ 
     344static caca_timer_t timer = {0, 0}; 
     345 
    344346int caca_rand(int min, int max) 
    345347{ 
     
    348350    if(need_init) 
    349351    { 
    350         srand(getpid() + time(NULL)); 
     352        srand(getpid() + _caca_getticks(&timer)); 
    351353        need_init = 0; 
    352354    } 
  • libcaca/trunk/caca/figfont.c

    r4817 r4822  
    2929#include "caca.h" 
    3030#include "caca_internals.h" 
     31 
     32#if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3 
     33int sprintf_s(char *s, size_t n, const char *fmt, ...) CACA_WEAK; 
     34#endif 
    3135 
    3236struct caca_charfont 
     
    624628 
    625629/* 
     630 * Functions for the mingw32 runtime 
     631 */ 
     632 
     633#if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3 
     634int sprintf_s(char *s, size_t n, const char *fmt, ...) 
     635{ 
     636    va_list args; 
     637    int ret; 
     638    va_start(args, fmt); 
     639    ret = vsnprintf(s, n, fmt, args); 
     640    va_end(args); 
     641    return ret; 
     642} 
     643#endif 
     644 
     645/* 
    626646 * XXX: The following functions are aliases. 
    627647 */ 
  • libcaca/trunk/caca/string.c

    r4819 r4822  
    3636#include "caca.h" 
    3737#include "caca_internals.h" 
     38 
     39#if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3 
     40int vsnprintf_s(char *s, size_t n, size_t c, 
     41                const char *fmt, va_list args) CACA_WEAK; 
     42#endif 
    3843 
    3944/** \brief Set cursor position. 
     
    597602    return 0; 
    598603} 
     604 
     605/* 
     606 * Functions for the mingw32 runtime 
     607 */ 
     608 
     609#if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3 
     610int vsnprintf_s(char *s, size_t n, size_t c, const char *fmt, va_list args) 
     611{ 
     612    return vsnprintf(s, n, fmt, args); 
     613} 
     614#endif 
    599615 
    600616/* 
Note: See TracChangeset for help on using the changeset viewer.