Configure dynamically generates SDL_config.h

I'm still wrestling with autoheader, but this should work for now...
Fixed lots of build problems with C library support disabled

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401345
This commit is contained in:
Sam Lantinga 2006-02-07 12:11:33 +00:00
parent dd8d77d906
commit 78516b5663
24 changed files with 513 additions and 117 deletions

View file

@ -113,11 +113,11 @@ int SDL_putenv(const char *variable)
}
/* Allocate memory for the variable */
new_variable = (char *)malloc(strlen(variable)+1);
new_variable = (char *)SDL_malloc(SDL_strlen(variable)+1);
if ( ! new_variable ) {
return(-1);
}
strcpy(new_variable, variable);
SDL_strcpy(new_variable, variable);
/* Actually put it into the environment */
added = 0;
@ -126,13 +126,13 @@ int SDL_putenv(const char *variable)
/* Check to see if it's already there... */
len = (value - name);
for ( ; SDL_env[i]; ++i ) {
if ( strncmp(SDL_env[i], name, len) == 0 ) {
if ( SDL_strncmp(SDL_env[i], name, len) == 0 ) {
break;
}
}
/* If we found it, just replace the entry */
if ( SDL_env[i] ) {
free(SDL_env[i]);
SDL_free(SDL_env[i]);
SDL_env[i] = new_variable;
added = 1;
}
@ -147,7 +147,7 @@ int SDL_putenv(const char *variable)
SDL_env[i++] = (char *)0;
added = 1;
} else {
free(new_variable);
SDL_free(new_variable);
}
}
return (added ? 0 : -1);
@ -161,9 +161,9 @@ char *SDL_getenv(const char *name)
value = (char *)0;
if ( SDL_env ) {
len = strlen(name);
len = SDL_strlen(name);
for ( i=0; SDL_env[i] && !value; ++i ) {
if ( (strncmp(SDL_env[i], name, len) == 0) &&
if ( (SDL_strncmp(SDL_env[i], name, len) == 0) &&
(SDL_env[i][len] == '=') ) {
value = &SDL_env[i][len+1];
}
@ -185,59 +185,59 @@ int main(int argc, char *argv[])
printf("Checking for non-existent variable... ");
fflush(stdout);
if ( ! getenv("EXISTS") ) {
if ( ! SDL_getenv("EXISTS") ) {
printf("okay\n");
} else {
printf("failed\n");
}
printf("Setting FIRST=VALUE1 in the environment... ");
fflush(stdout);
if ( putenv("FIRST=VALUE1") == 0 ) {
if ( SDL_putenv("FIRST=VALUE1") == 0 ) {
printf("okay\n");
} else {
printf("failed\n");
}
printf("Getting FIRST from the environment... ");
fflush(stdout);
value = getenv("FIRST");
if ( value && (strcmp(value, "VALUE1") == 0) ) {
value = SDL_getenv("FIRST");
if ( value && (SDL_strcmp(value, "VALUE1") == 0) ) {
printf("okay\n");
} else {
printf("failed\n");
}
printf("Setting SECOND=VALUE2 in the environment... ");
fflush(stdout);
if ( putenv("SECOND=VALUE2") == 0 ) {
if ( SDL_putenv("SECOND=VALUE2") == 0 ) {
printf("okay\n");
} else {
printf("failed\n");
}
printf("Getting SECOND from the environment... ");
fflush(stdout);
value = getenv("SECOND");
if ( value && (strcmp(value, "VALUE2") == 0) ) {
value = SDL_getenv("SECOND");
if ( value && (SDL_strcmp(value, "VALUE2") == 0) ) {
printf("okay\n");
} else {
printf("failed\n");
}
printf("Setting FIRST=NOVALUE in the environment... ");
fflush(stdout);
if ( putenv("FIRST=NOVALUE") == 0 ) {
if ( SDL_putenv("FIRST=NOVALUE") == 0 ) {
printf("okay\n");
} else {
printf("failed\n");
}
printf("Getting FIRST from the environment... ");
fflush(stdout);
value = getenv("FIRST");
if ( value && (strcmp(value, "NOVALUE") == 0) ) {
value = SDL_getenv("FIRST");
if ( value && (SDL_strcmp(value, "NOVALUE") == 0) ) {
printf("okay\n");
} else {
printf("failed\n");
}
printf("Checking for non-existent variable... ");
fflush(stdout);
if ( ! getenv("EXISTS") ) {
if ( ! SDL_getenv("EXISTS") ) {
printf("okay\n");
} else {
printf("failed\n");