mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
* options.c (scm_options, scm_init_options): GC-protect option
values of type SCM. (Thanks to Telford Tendys.)
This commit is contained in:
parent
d79fec7537
commit
263a691f04
1 changed files with 21 additions and 7 deletions
|
@ -114,18 +114,20 @@
|
||||||
SCM_SYMBOL (scm_yes_sym, "yes");
|
SCM_SYMBOL (scm_yes_sym, "yes");
|
||||||
SCM_SYMBOL (scm_no_sym, "no");
|
SCM_SYMBOL (scm_no_sym, "no");
|
||||||
|
|
||||||
|
static SCM protected_objects;
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
scm_options (new_mode, options, n, s)
|
scm_options (arg, options, n, s)
|
||||||
SCM new_mode;
|
SCM arg;
|
||||||
scm_option options[];
|
scm_option options[];
|
||||||
int n;
|
int n;
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
int i, docp = (!SCM_UNBNDP (new_mode)
|
int i, docp = (!SCM_UNBNDP (arg)
|
||||||
&& !SCM_NULLP (new_mode)
|
&& !SCM_NULLP (arg)
|
||||||
&& (SCM_IMP (new_mode) || SCM_NCONSP (new_mode)));
|
&& (SCM_IMP (arg) || SCM_NCONSP (arg)));
|
||||||
SCM ans = SCM_EOL, ls;
|
/* Let `arg' GC protect the arguments */
|
||||||
|
SCM new_mode = arg, ans = SCM_EOL, ls;
|
||||||
for (i = 0; i < n; ++i)
|
for (i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
ls = docp ? scm_cons ((SCM) options[i].doc, SCM_EOL) : ans;
|
ls = docp ? scm_cons ((SCM) options[i].doc, SCM_EOL) : ans;
|
||||||
|
@ -195,7 +197,15 @@ scm_options (new_mode, options, n, s)
|
||||||
cont:
|
cont:
|
||||||
new_mode = SCM_CDR (new_mode);
|
new_mode = SCM_CDR (new_mode);
|
||||||
}
|
}
|
||||||
for (i = 0; i < n; ++i) options[i].val = flags[i];
|
for (i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
if (options[i].type == SCM_OPTION_SCM)
|
||||||
|
SCM_SETCDR (protected_objects,
|
||||||
|
scm_cons (flags[i],
|
||||||
|
scm_delq1_x (options[i].val,
|
||||||
|
SCM_CDR (protected_objects))));
|
||||||
|
options[i].val = flags[i];
|
||||||
|
}
|
||||||
scm_must_free ((char *) flags);
|
scm_must_free ((char *) flags);
|
||||||
}
|
}
|
||||||
return ans;
|
return ans;
|
||||||
|
@ -215,6 +225,9 @@ scm_init_opts (func, options, n)
|
||||||
options[i].name = (char *) SCM_CAR (scm_sysintern0 (options[i].name));
|
options[i].name = (char *) SCM_CAR (scm_sysintern0 (options[i].name));
|
||||||
options[i].doc = (char *) scm_permanent_object (scm_take0str
|
options[i].doc = (char *) scm_permanent_object (scm_take0str
|
||||||
(options[i].doc));
|
(options[i].doc));
|
||||||
|
if (options[i].type == SCM_OPTION_SCM)
|
||||||
|
SCM_SETCDR (protected_objects,
|
||||||
|
scm_cons (options[i].val, SCM_CDR (protected_objects)));
|
||||||
}
|
}
|
||||||
func (SCM_UNDEFINED);
|
func (SCM_UNDEFINED);
|
||||||
}
|
}
|
||||||
|
@ -223,5 +236,6 @@ scm_init_opts (func, options, n)
|
||||||
void
|
void
|
||||||
scm_init_options ()
|
scm_init_options ()
|
||||||
{
|
{
|
||||||
|
protected_objects = scm_permanent_object (scm_cons (SCM_UNDEFINED, SCM_EOL));
|
||||||
#include "options.x"
|
#include "options.x"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue