(textonly repost) Problem with SDL_getenv under Win32

(reposted in text format only)
hello:
i’d like to report one thing about the implementation of SDL_getenv in
Win32 environment… its implemented in a manner that with two
consecutive calls to SDL_getenv can cause the 1st value to be stomped
over by the 2nd.

For example the code in SDL_dx5video.c (approx line 1179) - will never
set SD_windowx and SDL_windowy if both SDL_VIDEO_WINDOW_POS &
SDL_VIDEO_CENTER are specified.
if ( !SDL_windowX && !SDL_windowY ) {
window = SDL_getenv(“SDL_VIDEO_WINDOW_POS”);
center = SDL_getenv(“SDL_VIDEO_CENTERED”);
if ( window ) {
if ( SDL_sscanf(window, “%d,%d”, &x, &y) == 2 ) {
SDL_windowX = x;
SDL_windowY = y;
}
if ( SDL_strcmp(window, “center”) == 0 ) {
center = window;
}
}
}
Consider the case where i’ve set SDL_VIDEO_WINDOW_POS as “100,100” and
SDL_VIDEO_CENTERED as “yes”. In this case, the value of window after
the 2nd SDL_getenv call will become “yes”. This is 'cause SDL_getenv
returns a fixed pointer which is only allocated if the current buffer is
not large enough to take the value of the environment variable.

So, the above code will work with slight rearrangement (though I’d
prefer that SDL_getenv be fixed - more on that later!)

         if ( !SDL_windowX && !SDL_windowY ) {
             window = SDL_getenv("SDL_VIDEO_WINDOW_POS");
             if ( window ) {
                 if ( SDL_sscanf(window, "%d,%d", &x, &y) == 2 ) {
                     SDL_windowX = x;
                     SDL_windowY = y;
                 }
                 if ( SDL_strcmp(window, "center") == 0 ) {
                     center = window;
                 }
             }
             if (!center) /* assuming that SDL_VIDEO_WINDOW_POS 

specification of “center” overrides SDL_VIDEO_CENTERED */
center = SDL_getenv(“SDL_VIDEO_CENTERED”);
}

Hope that helps…

BTW: these env vars don’t seem to do anything in Win32 ?? (i’ll post
this separately)–

** Sheshadri Mantha**