/[guile]/guile/guile-core/libguile/posix.c
ViewVC logotype

Diff of /guile/guile-core/libguile/posix.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.102 by ossau, Fri Mar 15 10:37:40 2002 UTC revision 1.103 by mvo, Mon May 6 22:33:52 2002 UTC
# Line 1189  SCM_DEFINE (scm_putenv, "putenv", 1, 0, Line 1189  SCM_DEFINE (scm_putenv, "putenv", 1, 0,
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

Legend:
Removed from v.1.102  
changed lines
  Added in v.1.103

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26