works with the VS2010 runtime, too. Also reduce the stack size requirements to avoid depending on __chkstk_ms().tags/v0.99.beta19
| @@ -297,14 +297,15 @@ int caca_flush_figlet(caca_canvas_t *cv) | |||||
| static caca_charfont_t * open_charfont(char const *path) | static caca_charfont_t * open_charfont(char const *path) | ||||
| { | { | ||||
| #if !defined __KERNEL__ && defined HAVE_SNPRINTF | |||||
| char altpath[2048]; | |||||
| #endif | |||||
| char buf[2048]; | char buf[2048]; | ||||
| char hardblank[10]; | char hardblank[10]; | ||||
| caca_charfont_t *ff; | caca_charfont_t *ff; | ||||
| char *data = NULL; | char *data = NULL; | ||||
| caca_file_t *f; | caca_file_t *f; | ||||
| #if !defined __KERNEL__ && (defined HAVE_SNPRINTF || defined HAVE_SPRINTF_S) | |||||
| int const pathlen = 2048; | |||||
| char *altpath = NULL; | |||||
| #endif | |||||
| int i, j, size, comment_lines; | int i, j, size, comment_lines; | ||||
| ff = malloc(sizeof(caca_charfont_t)); | ff = malloc(sizeof(caca_charfont_t)); | ||||
| @@ -316,24 +317,31 @@ static caca_charfont_t * open_charfont(char const *path) | |||||
| /* Open font: if not found, try .tlf, then .flf */ | /* Open font: if not found, try .tlf, then .flf */ | ||||
| f = caca_file_open(path, "r"); | f = caca_file_open(path, "r"); | ||||
| #if !defined __KERNEL__ && defined HAVE_SNPRINTF | |||||
| #if (! defined(snprintf)) && ( defined(_WIN32) || defined(WIN32) ) && (! defined(__CYGWIN__)) | |||||
| #define snprintf _snprintf | |||||
| #endif | |||||
| #if !defined __KERNEL__ && (defined HAVE_SNPRINTF || defined HAVE_SPRINTF_S) | |||||
| if(!f) | |||||
| altpath = malloc(pathlen); | |||||
| if(!f) | if(!f) | ||||
| { | { | ||||
| snprintf(altpath, 2047, "%s.tlf", path); | |||||
| altpath[2047] = '\0'; | |||||
| #if defined HAVE_SPRINTF_S | |||||
| sprintf_s(altpath, pathlen - 1, "%s.tlf", path); | |||||
| #else | |||||
| snprintf(altpath, pathlen - 1, "%s.tlf", path); | |||||
| #endif | |||||
| altpath[pathlen - 1] = '\0'; | |||||
| f = caca_file_open(altpath, "r"); | f = caca_file_open(altpath, "r"); | ||||
| } | } | ||||
| if(!f) | if(!f) | ||||
| { | { | ||||
| snprintf(altpath, 2047, "%s.flf", path); | |||||
| altpath[2047] = '\0'; | |||||
| #if defined HAVE_SPRINTF_S | |||||
| sprintf_s(altpath, pathlen - 1, "%s.flf", path); | |||||
| #else | |||||
| snprintf(altpath, pathlen - 1, "%s.flf", path); | |||||
| #endif | |||||
| altpath[pathlen - 1] = '\0'; | |||||
| f = caca_file_open(altpath, "r"); | f = caca_file_open(altpath, "r"); | ||||
| } | } | ||||
| if (altpath) | |||||
| free(altpath); | |||||
| #endif | #endif | ||||
| if(!f) | if(!f) | ||||
| { | { | ||||
| @@ -336,7 +336,9 @@ int caca_vprintf(caca_canvas_t *cv, int x, int y, char const *format, | |||||
| if(cv->width - x + 1 > BUFSIZ) | if(cv->width - x + 1 > BUFSIZ) | ||||
| buf = malloc(cv->width - x + 1); | buf = malloc(cv->width - x + 1); | ||||
| #if defined(HAVE_VSNPRINTF) | |||||
| #if defined(HAVE_VSNPRINTF_S) | |||||
| vsnprintf_s(buf, cv->width - x + 1, _TRUNCATE, format, args); | |||||
| #elif defined(HAVE_VSNPRINTF) | |||||
| vsnprintf(buf, cv->width - x + 1, format, args); | vsnprintf(buf, cv->width - x + 1, format, args); | ||||
| #else | #else | ||||
| vsprintf(buf, format, args); | vsprintf(buf, format, args); | ||||
| @@ -120,7 +120,7 @@ fi | |||||
| AM_CONDITIONAL(USE_KERNEL, test "${ac_cv_my_have_kernel}" = "yes") | AM_CONDITIONAL(USE_KERNEL, test "${ac_cv_my_have_kernel}" = "yes") | ||||
| AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h endian.h unistd.h arpa/inet.h netinet/in.h winsock2.h errno.h locale.h getopt.h dlfcn.h termios.h) | AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h endian.h unistd.h arpa/inet.h netinet/in.h winsock2.h errno.h locale.h getopt.h dlfcn.h termios.h) | ||||
| AC_CHECK_FUNCS(signal ioctl snprintf vsnprintf getenv putenv strcasecmp htons) | |||||
| AC_CHECK_FUNCS(signal ioctl snprintf sprintf_s vsnprintf vsnprintf_s getenv putenv strcasecmp htons) | |||||
| AC_CHECK_FUNCS(usleep gettimeofday atexit) | AC_CHECK_FUNCS(usleep gettimeofday atexit) | ||||
| ac_cv_have_getopt_long="no" | ac_cv_have_getopt_long="no" | ||||
| @@ -43,6 +43,7 @@ | |||||
| #define HAVE_SLEEP 1 | #define HAVE_SLEEP 1 | ||||
| /* #undef HAVE_SLSMG_UTF8_ENABLE */ | /* #undef HAVE_SLSMG_UTF8_ENABLE */ | ||||
| #define HAVE_SNPRINTF 1 | #define HAVE_SNPRINTF 1 | ||||
| #define HAVE_SPRINTF_S 1 | |||||
| #define HAVE_STDARG_H 1 | #define HAVE_STDARG_H 1 | ||||
| #define HAVE_STDIO_H 1 | #define HAVE_STDIO_H 1 | ||||
| /* #undef HAVE_STDINT_H */ | /* #undef HAVE_STDINT_H */ | ||||
| @@ -59,6 +60,7 @@ | |||||
| /* #undef HAVE_UNISTD_H */ | /* #undef HAVE_UNISTD_H */ | ||||
| /* #undef HAVE_USLEEP */ | /* #undef HAVE_USLEEP */ | ||||
| /* #undef HAVE_VSNPRINTF */ | /* #undef HAVE_VSNPRINTF */ | ||||
| #define HAVE_VSNPRINTF_S 1 | |||||
| #define HAVE_WINDOWS_H 1 | #define HAVE_WINDOWS_H 1 | ||||
| #define HAVE_WINSOCK2_H 1 | #define HAVE_WINSOCK2_H 1 | ||||
| /* #undef HAVE_X11_XKBLIB_H */ | /* #undef HAVE_X11_XKBLIB_H */ | ||||