Don't include the manufacturer if it's already included in the product string
authorSam Lantinga <slouken@libsdl.org>
Tue, 10 Dec 2019 10:00:49 -0800
changeset 13326b0c5adc3162a
parent 13325 45d6830f0b53
child 13327 4f5f7a1ed7cc
Don't include the manufacturer if it's already included in the product string
src/joystick/hidapi/SDL_hidapijoystick.c
     1.1 --- a/src/joystick/hidapi/SDL_hidapijoystick.c	Tue Dec 10 09:38:10 2019 -0800
     1.2 +++ b/src/joystick/hidapi/SDL_hidapijoystick.c	Tue Dec 10 10:00:49 2019 -0800
     1.3 @@ -806,7 +806,11 @@
     1.4              size_t name_size = (SDL_strlen(manufacturer_string) + 1 + SDL_strlen(product_string) + 1);
     1.5              device->name = (char *)SDL_malloc(name_size);
     1.6              if (device->name) {
     1.7 -                SDL_snprintf(device->name, name_size, "%s %s", manufacturer_string, product_string);
     1.8 +                if (SDL_strncasecmp(manufacturer_string, product_string, SDL_strlen(manufacturer_string)) == 0) {
     1.9 +                    SDL_strlcpy(device->name, product_string, name_size);
    1.10 +                } else {
    1.11 +                    SDL_snprintf(device->name, name_size, "%s %s", manufacturer_string, product_string);
    1.12 +                }
    1.13              }
    1.14          }
    1.15          if (manufacturer_string) {