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,
256256static uint32_t abc_pattracktime (ABCHANDLE *h, uint32_t tracktime);
257257static 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
270260static 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// =====================================================================================
23572347static 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