src/filesystem/unix/SDL_sysfilesystem.c
changeset 7713 6074c53b0cda
parent 7697 678f71df2c6b
child 7714 1c227c5f5d8d
     1.1 --- a/src/filesystem/unix/SDL_sysfilesystem.c	Wed Aug 28 22:09:17 2013 -0400
     1.2 +++ b/src/filesystem/unix/SDL_sysfilesystem.c	Thu Aug 29 08:24:43 2013 -0700
     1.3 @@ -156,7 +156,7 @@
     1.4       * http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
     1.5       */
     1.6      const char *envr = SDL_getenv("XDG_DATA_HOME");
     1.7 -    const char *append = "/";
     1.8 +    const char *append;
     1.9      char *retval = NULL;
    1.10      char *ptr = NULL;
    1.11      size_t len = 0;
    1.12 @@ -169,18 +169,16 @@
    1.13              SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set");
    1.14              return NULL;
    1.15          }
    1.16 -        if (envr[SDL_strlen(envr) - 1] == '/') {
    1.17 -            append = ".local/share/";
    1.18 -        } else {
    1.19 -            append = "/.local/share/";
    1.20 -        }
    1.21 +        append = "/.local/share/";
    1.22      } else {
    1.23 -        if (envr[SDL_strlen(envr) - 1] == '/') {
    1.24 -            append = "";
    1.25 -        }
    1.26 +        append = "/";
    1.27      } /* if */
    1.28  
    1.29 -    len = SDL_strlen(envr) + SDL_strlen(append) + SDL_strlen(app) + 2;
    1.30 +    len = SDL_strlen(envr);
    1.31 +    if (envr[len - 1] == '/')
    1.32 +        append += 1;
    1.33 +
    1.34 +    len += SDL_strlen(append) + SDL_strlen(app) + 2;
    1.35      retval = (char *) SDL_malloc(len);
    1.36      if (!retval) {
    1.37          SDL_OutOfMemory();