Skip to content

Commit 45e5528

Browse files
authored
Merge pull request #32 from sezero/setenv
replace setenv() with putenv() and fix _MSC_VER condition
2 parents 1112541 + c5e2b2d commit 45e5528

File tree

4 files changed

+8
-25
lines changed

4 files changed

+8
-25
lines changed

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ else()
5656
endif()
5757
endif()
5858

59-
check_function_exists("setenv" HAVE_SETENV)
6059
check_function_exists("sinf" HAVE_SINF)
6160

6261
# Allow the developer to select if Dynamic or Static libraries are built
@@ -137,9 +136,6 @@ install(FILES
137136

138137
set(VERSION "0.8.9.1")
139138

140-
if(HAVE_SETENV)
141-
add_definitions(-DHAVE_SETENV)
142-
endif(HAVE_SETENV)
143139
if(HAVE_SINF)
144140
add_definitions(-DHAVE_SINF)
145141
endif(HAVE_SINF)

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ AC_CHECK_INCLUDES_DEFAULT
3131
AC_PROG_EGREP
3232

3333
AC_CHECK_HEADERS([inttypes.h stdint.h malloc.h])
34-
AC_CHECK_FUNCS(setenv sinf)
34+
AC_CHECK_FUNCS(sinf)
3535

3636
CXXFLAGS="$CXXFLAGS -fno-exceptions -Wall -ffast-math -fno-common -D_REENTRANT"
3737

@@ -98,6 +98,6 @@ MODPLUG_LIBRARY_VERSION=1:0:0
9898
AC_SUBST(MODPLUG_LIBRARY_VERSION)
9999

100100
AC_CONFIG_FILES([Makefile
101-
src/Makefile
101+
src/Makefile
102102
libmodplug.pc])
103103
AC_OUTPUT

src/config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
/* Define to 1 if you have the <memory.h> header file. */
1616
#undef HAVE_MEMORY_H
1717

18-
/* Define to 1 if you have the `setenv' function. */
19-
#undef HAVE_SETENV
20-
2118
/* Define to 1 if you have the `sinf' function. */
2219
#undef HAVE_SINF
2320

src/load_abc.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
#include "load_pat.h"
4141

42-
#if _MSC_VER >= 1600
42+
#if defined(_MSC_VER) && (_MSC_VER >= 1300)
4343
#define putenv _putenv
4444
#define strdup _strdup
4545
#endif
@@ -256,16 +256,6 @@ static void abc_add_setjumploop(ABCHANDLE *h, ABCTRACK *tp, uint32_t tracktime,
256256
static uint32_t abc_pattracktime(ABCHANDLE *h, uint32_t tracktime);
257257
static int abc_patno(ABCHANDLE *h, uint32_t tracktime);
258258

259-
#ifndef HAVE_SETENV
260-
static void setenv(const char *name, const char *value, int overwrite)
261-
{
262-
int len = strlen(name)+1+strlen(value)+1;
263-
char *str = (char *)malloc(len);
264-
sprintf(str, "%s=%s", name, value);
265-
putenv(str);
266-
free(str);
267-
}
268-
#endif
269259

270260
static int abc_isvalidchar(char c) {
271261
return(isalpha(c) || isdigit(c) || isspace(c) || c == '%' || c == ':');
@@ -2356,9 +2346,9 @@ BOOL CSoundFile::TestABC(const BYTE *lpStream, DWORD dwMemLength)
23562346
// =====================================================================================
23572347
static ABCHANDLE *ABC_Init(void)
23582348
{
2349+
static char buf[40];
23592350
ABCHANDLE *retval;
23602351
char *p;
2361-
char buf[10];
23622352
retval = (ABCHANDLE *)calloc(1,sizeof(ABCHANDLE));
23632353
if( !retval ) return NULL;
23642354
retval->track = NULL;
@@ -2376,16 +2366,16 @@ static ABCHANDLE *ABC_Init(void)
23762366
retval->pickrandom = atoi(p);
23772367
if( *p == '-' ) {
23782368
retval->pickrandom = atoi(p+1)-1; // xmms preloads the file
2379-
sprintf(buf,"-%ld",retval->pickrandom+2);
2380-
setenv(ABC_ENV_NORANDOMPICK, buf, 1);
2369+
sprintf(buf,"%s=-%ld",ABC_ENV_NORANDOMPICK,retval->pickrandom+2);
2370+
putenv(buf);
23812371
}
23822372
}
23832373
else {
23842374
srandom((uint32_t)time(0)); // initialize random generator with seed
23852375
retval->pickrandom = 1+(int)(10000.0*random()/(RAND_MAX+1.0));
23862376
// can handle pickin' from songbooks with 10.000 songs
2387-
sprintf(buf,"-%ld",retval->pickrandom); // xmms preloads the file
2388-
setenv(ABC_ENV_NORANDOMPICK, buf, 1);
2377+
sprintf(buf,"%s=-%ld",ABC_ENV_NORANDOMPICK,retval->pickrandom); // xmms preloads the file
2378+
putenv(buf);
23892379
}
23902380
return retval;
23912381
}

0 commit comments

Comments
 (0)