1189 |
char *ptr; |
char *ptr; |
1190 |
|
|
1191 |
SCM_VALIDATE_STRING (1, str); |
SCM_VALIDATE_STRING (1, str); |
1192 |
/* must make a new copy to be left in the environment, safe from gc. */ |
|
1193 |
ptr = malloc (SCM_STRING_LENGTH (str) + 1); |
if (strchr (SCM_STRING_CHARS (str), '=') == NULL) |
1194 |
if (ptr == NULL) |
{ |
1195 |
SCM_MEMORY_ERROR; |
/* No '=' in argument means we should remove the variable from |
1196 |
strncpy (ptr, SCM_STRING_CHARS (str), SCM_STRING_LENGTH (str)); |
the environment. Not all putenvs understand this. To be |
1197 |
ptr[SCM_STRING_LENGTH (str)] = 0; |
safe, we do it explicitely using unsetenv. */ |
1198 |
rv = putenv (ptr); |
unsetenv (SCM_STRING_CHARS (str)); |
1199 |
if (rv < 0) |
} |
1200 |
SCM_SYSERROR; |
else |
1201 |
|
{ |
1202 |
|
/* must make a new copy to be left in the environment, safe from gc. */ |
1203 |
|
ptr = malloc (SCM_STRING_LENGTH (str) + 1); |
1204 |
|
if (ptr == NULL) |
1205 |
|
SCM_MEMORY_ERROR; |
1206 |
|
strncpy (ptr, SCM_STRING_CHARS (str), SCM_STRING_LENGTH (str)); |
1207 |
|
ptr[SCM_STRING_LENGTH (str)] = 0; |
1208 |
|
rv = putenv (ptr); |
1209 |
|
if (rv < 0) |
1210 |
|
SCM_SYSERROR; |
1211 |
|
} |
1212 |
return SCM_UNSPECIFIED; |
return SCM_UNSPECIFIED; |
1213 |
} |
} |
1214 |
#undef FUNC_NAME |
#undef FUNC_NAME |