2007-01-19 Han-Wen Nienhuys <hanwen@lilypond.org>
+ * options.c (scm_options_try): new function. This allows error
+ reporting before changing options in a critical section.
+
* srcprop.c: use double cell for storing source-properties. Put
filename in the plist, and share between srcprops if possible.
Remove specialized storage.
* formed option setting, i. e. if for every non-boolean option a value is
* given. For this reason, the function applies all changes to a copy of the
* original setting in memory. Only if 'args' was successfully processed,
- * the new setting will overwrite the old one. */
+ * the new setting will overwrite the old one.
+ *
+ * If DRY_RUN is set, don't change anything. This is useful for trying out an option
+ * before entering a critical section.
+ */
static void
-change_option_setting (SCM args, scm_t_option options[], const char *s)
+change_option_setting (SCM args, scm_t_option options[], const char *s,
+ int dry_run)
{
unsigned int i;
SCM locally_protected_args = args;
args = SCM_CDR (args);
}
+ if (dry_run)
+ return;
+
for (i = 0; options[i].name; ++i)
{
if (options[i].type == SCM_OPTION_SCM)
SCM
scm_options (SCM args, scm_t_option options[], const char *s)
+{
+ return scm_options_try (args, options, s, 0);
+}
+
+SCM
+scm_options_try (SCM args, scm_t_option options[], const char *s,
+ int dry_run)
{
if (SCM_UNBNDP (args))
return get_option_setting (options);
SCM old_setting;
SCM_ASSERT (scm_is_true (scm_list_p (args)), args, 1, s);
old_setting = get_option_setting (options);
- change_option_setting (args, options, s);
+ change_option_setting (args, options, s, dry_run);
return old_setting;
}
}
#define SCM_OPTION_SCM 2
+SCM_API SCM scm_options_try (SCM args, scm_t_option options[], const char *s, int dry_run);
SCM_API SCM scm_options (SCM, scm_t_option [], const char*);
SCM_API void scm_init_opts (SCM (*) (SCM), scm_t_option []);
SCM_API void scm_init_options (void);