From d4740806159e7e398a8163f747c4ecb63544455c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 22 Nov 2009 07:00:26 +0000 Subject: [PATCH] More fixes to compile under Visual C++ --- test/automated/SDL_at.c | 27 ++++++++++++++++++++++++++- test/automated/SDL_at.h | 3 +-- test/automated/common/common.c | 4 ++-- test/automated/render/render.c | 10 ++++------ test/automated/rwops/rwops.c | 2 +- test/automated/testsdl.c | 20 ++++++++++++++++++-- 6 files changed, 52 insertions(+), 14 deletions(-) diff --git a/test/automated/SDL_at.c b/test/automated/SDL_at.c index db9aa5d7a..97cd92d51 100644 --- a/test/automated/SDL_at.c +++ b/test/automated/SDL_at.c @@ -242,7 +242,7 @@ int SDL_ATvassert( int condition, const char *msg, ... ) if (!condition) { /* Get message. */ va_start( args, msg ); - vsnprintf( buf, sizeof(buf), msg, args ); + SDL_vsnprintf( buf, sizeof(buf), msg, args ); va_end( args ); /* Failed message. */ SDL_ATassertFailed( buf ); @@ -281,6 +281,31 @@ int SDL_ATprintErr( const char *msg, ... ) } +/** + * @brief Displays a message. + */ +int SDL_ATprint( const char *msg, ... ) +{ + va_list ap; + int ret; + + /* Only print if not quiet. */ + if (at_quiet) + return 0; + + /* Make sure there is something to print. */ + if (msg == NULL) + return 0; + else { + va_start(ap, msg); + ret = vfprintf( stdout, msg, ap ); + va_end(ap); + } + + return ret; +} + + /** * @brief Displays a verbose message. */ diff --git a/test/automated/SDL_at.h b/test/automated/SDL_at.h index 3d3562f91..6bd9680bd 100644 --- a/test/automated/SDL_at.h +++ b/test/automated/SDL_at.h @@ -136,8 +136,7 @@ int SDL_ATprintErr( const char *msg, ... ); * @param msg printf formatted string to display. * @return Number of character printed. */ -#define SDL_ATprint(msg, args...) \ - SDL_ATprintVerbose( 0, msg, ## args) +int SDL_ATprint( const char *msg, ... ); /** * @brief Prints some verbose text. * diff --git a/test/automated/common/common.c b/test/automated/common/common.c index fb0e14f01..7abf0a68a 100644 --- a/test/automated/common/common.c +++ b/test/automated/common/common.c @@ -42,7 +42,7 @@ int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img, int allowable_ case 2: case 3: ret += 1; - printf("%d BPP not supported yet.\n",bpp); + /*printf("%d BPP not supported yet.\n",bpp);*/ break; case 4: @@ -86,9 +86,9 @@ int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img, int allowable_ if (bpp == 4) { for (j=0; jh; j++) { for (i=0; iw; i++) { + Uint8 R, G, B, A; p = (Uint8 *)sur->pixels + j * sur->pitch + i * bpp; pd = (Uint8 *)img->pixel_data + (j*img->width + i) * img->bytes_per_pixel; - Uint8 R, G, B, A; R = pd[0]; G = pd[1]; diff --git a/test/automated/render/render.c b/test/automated/render/render.c index 9827559ae..4c61a031a 100644 --- a/test/automated/render/render.c +++ b/test/automated/render/render.c @@ -55,8 +55,6 @@ static int render_testBlitBlend (void); */ static int render_compare( const char *msg, const SurfaceImage_t *s, int allowable_error ) { - (void) msg; - (void) s; int ret; Uint8 pix[4*80*60]; SDL_Surface *testsur; @@ -1005,7 +1003,7 @@ int test_render (void) /* * Initialize testsuite. */ - snprintf( msg, sizeof(msg) , "Rendering with %s driver", driver ); + SDL_snprintf( msg, sizeof(msg) , "Rendering with %s driver", driver ); SDL_ATinit( msg ); /* @@ -1018,7 +1016,7 @@ int test_render (void) goto err_cleanup; /* Check to see if it's the one we want. */ str = SDL_GetCurrentVideoDriver(); - if (SDL_ATassert( "SDL_GetCurrentVideoDriver", strcmp(driver,str)==0)) + if (SDL_ATassert( "SDL_GetCurrentVideoDriver", SDL_strcmp(driver,str)==0)) goto err_cleanup; /* Create window. */ wid = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, @@ -1027,7 +1025,7 @@ int test_render (void) goto err_cleanup; /* Check title. */ str = SDL_GetWindowTitle( wid ); - if (SDL_ATassert( "SDL_GetWindowTitle", strcmp(msg,str)==0)) + if (SDL_ATassert( "SDL_GetWindowTitle", SDL_strcmp(msg,str)==0)) goto err_cleanup; /* Get renderers. */ nr = SDL_GetNumRenderDrivers(); @@ -1051,7 +1049,7 @@ int test_render (void) goto err_cleanup; /* Set testcase name. */ - snprintf( msg, sizeof(msg), "Renderer %s", renderer.name ); + SDL_snprintf( msg, sizeof(msg), "Renderer %s", renderer.name ); SDL_ATprintVerbose( 1, " %d) %s\n", j+1, renderer.name ); SDL_ATbegin( msg ); diff --git a/test/automated/rwops/rwops.c b/test/automated/rwops/rwops.c index 3b402f217..37a83c1e9 100644 --- a/test/automated/rwops/rwops.c +++ b/test/automated/rwops/rwops.c @@ -100,7 +100,7 @@ static int rwops_testGeneric( SDL_RWops *rw, int write ) if (SDL_ATassert( "Reading with SDL_RWread", i == sizeof(hello_world)-1 )) return 1; if (SDL_ATassert( "Memory read does not match memory written", - memcmp( buf, hello_world, sizeof(hello_world)-1 ) == 0 )) + SDL_memcmp( buf, hello_world, sizeof(hello_world)-1 ) == 0 )) return 1; /* More seek tests. */ diff --git a/test/automated/testsdl.c b/test/automated/testsdl.c index c64fe4375..cb90647a8 100644 --- a/test/automated/testsdl.c +++ b/test/automated/testsdl.c @@ -16,17 +16,21 @@ #include "render/render.h" #include "audio/audio.h" +#if defined(WIN32) +#define NO_GETOPT +#endif #if defined(__QNXNTO__) #define NO_GETOPT_LONG 1 #endif /* __QNXNTO__ */ #include /* printf */ #include /* exit */ +#ifndef NO_GETOPT #include /* getopt */ -#include /* strcmp */ #if !defined(NO_GETOPT_LONG) #include /* getopt_long */ #endif /* !NO_GETOPT_LONG */ +#endif /* !NO_GETOPT */ /* @@ -51,6 +55,11 @@ static void parse_options( int argc, char *argv[] ); /** * @brief Displays program usage. */ +#ifdef NO_GETOPT +static void print_usage( const char *name ) +{ +} +#else #if !defined(NO_GETOPT_LONG) static void print_usage( const char *name ) { @@ -84,10 +93,16 @@ static void print_usage( const char *name ) printf(" -h, display this message and exit\n"); } #endif /* NO_GETOPT_LONG */ +#endif /* NO_GETOPT */ /** * @brief Handles the options. */ +#ifdef NO_GETOPT +static void parse_options( int argc, char *argv[] ) +{ +} +#else #if !defined(NO_GETOPT_LONG) static void parse_options( int argc, char *argv[] ) { @@ -239,6 +254,7 @@ static void parse_options( int argc, char *argv[] ) } } #endif /* NO_GETOPT_LONG */ +#endif /* NO_GETOPT */ /** * @brief Main entry point. @@ -283,7 +299,7 @@ int main( int argc, char *argv[] ) ver.major, ver.minor, ver.patch, rev ); SDL_ATprintErr( "System is running %s and is %s endian\n", SDL_GetPlatform(), -#ifdef SDL_LIL_ENDIAN +#if SDL_BYTEORDER == SDL_LIL_ENDIAN "little" #else "big"