Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
More fixes to compile under Visual C++
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Nov 22, 2009
1 parent a8e2e9a commit d474080
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 14 deletions.
27 changes: 26 additions & 1 deletion test/automated/SDL_at.c
Expand Up @@ -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 );
Expand Down Expand Up @@ -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.
*/
Expand Down
3 changes: 1 addition & 2 deletions test/automated/SDL_at.h
Expand Up @@ -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.
*
Expand Down
4 changes: 2 additions & 2 deletions test/automated/common/common.c
Expand Up @@ -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:
Expand Down Expand Up @@ -86,9 +86,9 @@ int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img, int allowable_
if (bpp == 4) {
for (j=0; j<sur->h; j++) {
for (i=0; i<sur->w; 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];
Expand Down
10 changes: 4 additions & 6 deletions test/automated/render/render.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );

/*
Expand All @@ -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,
Expand All @@ -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();
Expand All @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion test/automated/rwops/rwops.c
Expand Up @@ -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. */
Expand Down
20 changes: 18 additions & 2 deletions test/automated/testsdl.c
Expand Up @@ -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 <stdio.h> /* printf */
#include <stdlib.h> /* exit */
#ifndef NO_GETOPT
#include <unistd.h> /* getopt */
#include <string.h> /* strcmp */
#if !defined(NO_GETOPT_LONG)
#include <getopt.h> /* getopt_long */
#endif /* !NO_GETOPT_LONG */
#endif /* !NO_GETOPT */


/*
Expand All @@ -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 )
{
Expand Down Expand Up @@ -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[] )
{
Expand Down Expand Up @@ -239,6 +254,7 @@ static void parse_options( int argc, char *argv[] )
}
}
#endif /* NO_GETOPT_LONG */
#endif /* NO_GETOPT */

/**
* @brief Main entry point.
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit d474080

Please sign in to comment.