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:
parent
dd8d77d906
commit
78516b5663
24 changed files with 513 additions and 117 deletions
|
@ -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");
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "SDL_types.h"
|
||||
#include "SDL_ctype.h"
|
||||
#include "SDL_stdlib.h"
|
||||
#include "SDL_string.h"
|
||||
|
||||
|
||||
|
@ -175,7 +176,7 @@ static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valu
|
|||
#endif
|
||||
#endif /* SDL_HAS_64BIT_TYPE */
|
||||
|
||||
#ifndef HAVE_SSCANF
|
||||
#if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOD)
|
||||
static size_t SDL_ScanFloat(const char *text, double *valuep)
|
||||
{
|
||||
const char *textstart = text;
|
||||
|
@ -322,6 +323,18 @@ char *SDL_strncpy(char *dst, const char *src, size_t maxlen)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
char *SDL_strdup(const char *string)
|
||||
{
|
||||
size_t len = SDL_strlen(string);
|
||||
char *newstr = SDL_malloc(len+1);
|
||||
if ( newstr ) {
|
||||
SDL_strcpy(newstr, string);
|
||||
}
|
||||
return newstr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE__STRREV
|
||||
char *SDL_strrev(char *string)
|
||||
{
|
||||
|
@ -549,6 +562,20 @@ Sint64 SDL_strtoll(const char *string, char **endp, int base)
|
|||
|
||||
#endif /* SDL_HAS_64BIT_TYPE */
|
||||
|
||||
#ifndef HAVE_STRTOD
|
||||
double SDL_strtod(const char *string, char **endp)
|
||||
{
|
||||
size_t len;
|
||||
double value;
|
||||
|
||||
len = SDL_ScanFloat(string, &value);
|
||||
if ( endp ) {
|
||||
*endp = (char *)string + len;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCMP
|
||||
int SDL_strcmp(const char *str1, const char *str2)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue