Allow abbreviated strings to be used for driver names.
authorSam Lantinga <slouken@libsdl.org>
Mon, 18 Feb 2013 20:14:24 -0800
changeset 6900767690d1c013
parent 6899 f75b1bd8eabc
child 6901 57dcaecb19e5
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
src/video/SDL_video.c
     1.1 --- a/src/audio/SDL_audio.c	Mon Feb 18 18:28:02 2013 -0800
     1.2 +++ b/src/audio/SDL_audio.c	Mon Feb 18 20:14:24 2013 -0800
     1.3 @@ -580,8 +580,8 @@
     1.4      for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
     1.5          /* make sure we should even try this driver before doing so... */
     1.6          const AudioBootStrap *backend = bootstrap[i];
     1.7 -        if (((driver_name) && (SDL_strcasecmp(backend->name, driver_name))) ||
     1.8 -            ((!driver_name) && (backend->demand_only))) {
     1.9 +        if ((driver_name && (SDL_strncasecmp(backend->name, driver_name, SDL_strlen(driver_name)) != 0)) ||
    1.10 +            (!driver_name && backend->demand_only)) {
    1.11              continue;
    1.12          }
    1.13  
     2.1 --- a/src/video/SDL_video.c	Mon Feb 18 18:28:02 2013 -0800
     2.2 +++ b/src/video/SDL_video.c	Mon Feb 18 20:14:24 2013 -0800
     2.3 @@ -437,7 +437,7 @@
     2.4      }
     2.5      if (driver_name != NULL) {
     2.6          for (i = 0; bootstrap[i]; ++i) {
     2.7 -            if (SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) {
     2.8 +            if (SDL_strncasecmp(bootstrap[i]->name, driver_name, SDL_strlen(driver_name)) == 0) {
     2.9                  video = bootstrap[i]->create(index);
    2.10                  break;
    2.11              }