+ /* Check for non-terminating markups, e.g. recursive calls with
+ * changing arguments */
+ SCM opt_depth = ly_get_option (ly_symbol2scm ("max-markup-depth"));
+ size_t max_depth = robust_scm2int (opt_depth, 1024);
+
+ // Don't use SCM_F_DYNWIND_REWINDABLE since it may be expensive
+ // without any obvious use for retaining continuations into
+ // markup expansion
+ scm_dynwind_begin ((scm_t_dynwind_flags)0);
+ // scm_dynwind_rewind_handler (markup_up_depth, 0, SCM_F_WIND_EXPLICITLY);
+ markup_up_depth (0);
+ scm_dynwind_unwind_handler (markup_down_depth, 0, SCM_F_WIND_EXPLICITLY);
+ if (markup_depth > max_depth)
+ {
+ scm_dynwind_end ();
+ string name = ly_symbol2string (scm_procedure_name (func));
+ // TODO: Also print the arguments of the markup!
+ non_fatal_error (_f ("Markup depth exceeds maximal value of %d; "
+ "Markup: %s", max_depth, name.c_str ()));
+ return Stencil ().smobbed_copy ();
+ }
+
+ SCM retval = scm_apply_2 (func, layout_smob, props, args);
+ scm_dynwind_end ();
+ return retval;