From 1cb9a47f70678db244df02d8c51cfbb28f1ab071 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 18 Feb 2013 20:14:24 -0800 Subject: [PATCH] Allow abbreviated strings to be used for driver names. This allows people to use "pulse" with both SDL 1.2 and 2.0 --- src/audio/SDL_audio.c | 4 ++-- src/video/SDL_video.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 50981f431..090e0144b 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -580,8 +580,8 @@ SDL_AudioInit(const char *driver_name) for (i = 0; (!initialized) && (bootstrap[i]); ++i) { /* make sure we should even try this driver before doing so... */ const AudioBootStrap *backend = bootstrap[i]; - if (((driver_name) && (SDL_strcasecmp(backend->name, driver_name))) || - ((!driver_name) && (backend->demand_only))) { + if ((driver_name && (SDL_strncasecmp(backend->name, driver_name, SDL_strlen(driver_name)) != 0)) || + (!driver_name && backend->demand_only)) { continue; } diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 97829d915..5109cb977 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -437,7 +437,7 @@ SDL_VideoInit(const char *driver_name) } if (driver_name != NULL) { for (i = 0; bootstrap[i]; ++i) { - if (SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) { + if (SDL_strncasecmp(bootstrap[i]->name, driver_name, SDL_strlen(driver_name)) == 0) { video = bootstrap[i]->create(index); break; }