mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
* environments.c: Don't use '==' to compare SCM objects.
* posix.c (scm_getgroups): Don't create a redundant string object.
This commit is contained in:
parent
0f87853a56
commit
66460dfba3
3 changed files with 30 additions and 29 deletions
|
@ -1,3 +1,10 @@
|
|||
2000-11-01 Dirk Herrmann <D.Herrmann@tu-bs.de>
|
||||
|
||||
* environments.c (obarray_replace, obarray_retrieve,
|
||||
obarray_remove): Don't use '==' to compare SCM objects.
|
||||
|
||||
* posix.c (scm_getgroups): Don't create a redundant string.
|
||||
|
||||
2000-11-01 Dirk Herrmann <D.Herrmann@tu-bs.de>
|
||||
|
||||
* symbols.c (scm_sym2vcell, scm_sym2ovcell_soft,
|
||||
|
|
|
@ -545,7 +545,7 @@ obarray_replace (SCM obarray, SCM symbol, SCM data)
|
|||
for (lsym = SCM_VELTS (obarray)[hash]; !SCM_NULLP (lsym); lsym = SCM_CDR (lsym))
|
||||
{
|
||||
SCM old_entry = SCM_CAR (lsym);
|
||||
if (SCM_CAR (old_entry) == symbol)
|
||||
if (SCM_EQ_P (SCM_CAR (old_entry), symbol))
|
||||
{
|
||||
SCM_SETCAR (lsym, new_entry);
|
||||
return old_entry;
|
||||
|
@ -571,7 +571,7 @@ obarray_retrieve (SCM obarray, SCM sym)
|
|||
for (lsym = SCM_VELTS (obarray)[hash]; !SCM_NULLP (lsym); lsym = SCM_CDR (lsym))
|
||||
{
|
||||
SCM entry = SCM_CAR (lsym);
|
||||
if (SCM_CAR (entry) == sym)
|
||||
if (SCM_EQ_P (SCM_CAR (entry), sym))
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
@ -596,7 +596,7 @@ obarray_remove (SCM obarray, SCM sym)
|
|||
lsym = *(lsymp = SCM_CDRLOC (lsym)))
|
||||
{
|
||||
SCM entry = SCM_CAR (lsym);
|
||||
if (SCM_CAR (entry) == sym)
|
||||
if (SCM_EQ_P (SCM_CAR (entry), sym))
|
||||
{
|
||||
*lsymp = SCM_CDR (lsym);
|
||||
return entry;
|
||||
|
|
|
@ -205,33 +205,27 @@ SCM_DEFINE (scm_getgroups, "getgroups", 0, 0, 0,
|
|||
"Returns a vector of integers representing the current supplimentary group IDs.")
|
||||
#define FUNC_NAME s_scm_getgroups
|
||||
{
|
||||
SCM grps, ans;
|
||||
int ngroups = getgroups (0, NULL);
|
||||
if (!ngroups)
|
||||
SCM_SYSERROR;
|
||||
SCM_NEWCELL(grps);
|
||||
SCM_DEFER_INTS;
|
||||
{
|
||||
SCM ans;
|
||||
int ngroups;
|
||||
scm_sizet size;
|
||||
GETGROUPS_T *groups;
|
||||
int val;
|
||||
|
||||
groups = SCM_MUST_MALLOC_TYPE_NUM(GETGROUPS_T,ngroups);
|
||||
val = getgroups(ngroups, groups);
|
||||
if (val < 0)
|
||||
{
|
||||
int en = errno;
|
||||
scm_must_free((char *)groups);
|
||||
errno = en;
|
||||
ngroups = getgroups (0, NULL);
|
||||
if (ngroups <= 0)
|
||||
SCM_SYSERROR;
|
||||
}
|
||||
SCM_SETCHARS(grps, groups); /* set up grps as a GC protect */
|
||||
SCM_SETLENGTH(grps, 0L + ngroups * sizeof(GETGROUPS_T), scm_tc7_string);
|
||||
ans = scm_make_vector (SCM_MAKINUM(ngroups), SCM_UNDEFINED);
|
||||
while (--ngroups >= 0) SCM_VELTS(ans)[ngroups] = SCM_MAKINUM(groups[ngroups]);
|
||||
SCM_SETCHARS(grps, groups); /* to make sure grps stays around. */
|
||||
SCM_ALLOW_INTS;
|
||||
|
||||
size = ngroups * sizeof (GETGROUPS_T);
|
||||
groups = scm_must_malloc (size, FUNC_NAME);
|
||||
getgroups (ngroups, groups);
|
||||
|
||||
ans = scm_make_vector (SCM_MAKINUM (ngroups), SCM_UNDEFINED);
|
||||
while (--ngroups >= 0)
|
||||
SCM_VELTS (ans) [ngroups] = SCM_MAKINUM (groups [ngroups]);
|
||||
|
||||
scm_must_free (groups);
|
||||
scm_done_free (size);
|
||||
|
||||
return ans;
|
||||
}
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue