- file_ = scm_open_file (scm_makfrom0str (name.to_str0 ()),
- scm_makfrom0str ("w"));
-
- SCM exp = scm_list_n (ly_symbol2scm ("find-dumper"),
- scm_makfrom0str (output_format_global.to_str0 ()),
- SCM_UNDEFINED);
-
- output_func_ = scm_primitive_eval (exp);
+ /* FIXME: output-lib should be module, that can be imported. */
+#define IMPORT_LESS 1 // only import the list of IMPORTS
+#if IMPORT_LESS
+ scm_c_use_module ("lily");
+ scm_c_use_module ("ice-9 regex");
+ scm_c_use_module ("srfi srfi-1");
+ scm_c_use_module ("srfi srfi-13");
+#endif
+ char const *imports[] = {
+ "lilypond-version", /* from lily */
+ "ly:output-def-scope",
+ "ly:gulp-file",
+ "ly:number->string",
+ "ly:ragged-page-breaks",
+ "ly:optimal-page-breaks",
+
+ "ly:number-pair->string", /* output-lib.scm */
+ "ly:numbers->string",
+ "ly:inexact->string",
+
+ "assoc-get",
+#if IMPORT_LESS
+ "remove", /* from srfi srfi-1 */
+ "string-index", /* from srfi srfi-13 */
+ "string-join",
+ "regexp-substitute/global", /* from (ice9 regex) */
+#endif
+ 0,
+ };
+
+ for (int i = 0; imports[i]; i++)
+ {
+ SCM s = ly_symbol2scm (imports[i]);
+ scm_module_define (output_module_, s, scm_primitive_eval (s));
+ }
+#ifndef IMPORT_LESS // rather crude, esp for safe-mode let's not
+ SCM m = scm_set_current_module (output_module_);
+ /* not present in current module*/
+ scm_c_use_module ("ice-9 regex");
+ scm_c_use_module ("srfi srfi-13");
+ /* Need only a few of these, see above
+ scm_c_use_module ("lily"); */
+ scm_set_current_module (m);
+#endif