]> git.donarmstrong.com Git - lilypond.git/commitdiff
Evaluate -d option setting and -e code inside GUILE.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 10 Jan 2007 15:56:02 +0000 (16:56 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 10 Jan 2007 15:56:02 +0000 (16:56 +0100)
lily/include/main.hh
lily/main.cc
lily/program-option.cc
scm/layout-beam.scm
scm/lily.scm

index 29b08a3f4021679dabbacd1fc47655f8d1b8d403..08194ca22f692a6a352dcac358c6a08a65f55a8f 100644 (file)
@@ -38,6 +38,9 @@ extern bool point_and_click_global;
 extern string prefix_directory;
 extern bool use_object_keys;
 extern bool strict_infinity_checking;
+extern string init_scheme_code_string_global;
+extern string init_scheme_variables_global;
+
 /*
   todo: collect in Output_option struct?
 */
index 2b715cdcb7e526bc22ff3574868e47662b2c4e2a..9161511e68370b9caa46caf6e91942dab6387799 100644 (file)
@@ -77,8 +77,8 @@ bool be_verbose_global = false;
 
 /* Scheme code to execute before parsing, after .scm init.
    This is where -e arguments are appended to.  */
-string init_scheme_code_string;
-string init_scheme_variables;
+string init_scheme_code_string_global;
+string init_scheme_variables_global;
 
 /* Generate preview of first system.  */
 bool make_preview = false;
@@ -178,8 +178,6 @@ static Long_option_init options_static[]
   {_i ("FILE"), "output", 'o',  _i ("write output to FILE (suffix will be added)")},
   {0, "preview", 'p',  _i ("generate a preview of the first system")},
   {0, "relocate", 0, _i ("relocate using directory of lilypond program")},
-  {0, "safe-mode", 's',  _i ("disallow unsafe Scheme and PostScript\n"
-                            "operations")},
   {0, "version", 'v',  _i ("show version number and exit")},
   {0, "verbose", 'V', _i ("be verbose")},
   {0, "warranty", 'w',  _i ("show warranty and copyright")},
@@ -388,6 +386,8 @@ main_with_guile (void *, int, char **)
                          || output_backend_global == "texstr");
 
   is_pango_format_global = !is_TeX_format_global;
+  init_scheme_variables_global = "(list " + init_scheme_variables_global + ")";
+  init_scheme_code_global = "(begin " + init_scheme_code_global + ")";
 
   ly_c_init_guile ();
   call_constructors ();
@@ -396,24 +396,6 @@ main_with_guile (void *, int, char **)
   init_freetype ();
   ly_reset_all_fonts ();
 
-  if (!init_scheme_variables.empty ()
-      || !init_scheme_code_string.empty ())
-    {
-      init_scheme_variables = "(map (lambda (x) (ly:set-option (car x) (cdr x))) (list "
-       + init_scheme_variables + "))";
-
-      init_scheme_code_string
-       = "(begin #t "
-       + init_scheme_variables
-       + init_scheme_code_string
-       + ")";
-
-      char const *str0 = init_scheme_code_string.c_str ();
-
-      if (be_verbose_global)
-       progress_indication (_f ("Evaluating %s", str0));
-      scm_c_eval_string ((char *) str0);
-    }
 
   /* We accept multiple independent music files on the command line to
      reduce compile time when processing lots of small files.
@@ -508,7 +490,7 @@ parse_argv (int argc, char **argv)
                val = arg.substr (eq + 1, arg.length () - 1);
              }
 
-           init_scheme_variables
+           init_scheme_variables_global
              += "(cons \'" + key + "  " + val + ")\n";
          }
          break;
@@ -527,8 +509,9 @@ parse_argv (int argc, char **argv)
        case 'j':
          jail_spec = option_parser->optional_argument_str0_;
          break;
+         
        case 'e':
-         init_scheme_code_string += option_parser->optional_argument_str0_;
+         init_scheme_code_string_global += option_parser->optional_argument_str0_ + string (" ");
          break;
        case 'w':
          warranty ();
@@ -564,10 +547,6 @@ parse_argv (int argc, char **argv)
        case 'V':
          be_verbose_global = true;
          break;
-       case 's':
-         init_scheme_variables
-           += "(cons \'safe #t)\n";
-         break;
        case 'p':
          make_preview = true;
          break;
index 80930efbf329fe79b36b7b292f79f7a12b1934b5..64318c00a80982b7add4acb77589fd4e1afb4acd 100644 (file)
@@ -210,6 +210,18 @@ LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val),
   return SCM_UNSPECIFIED;
 }
 
+LY_DEFINE (ly_command_line_options, "ly:command-line-options", 0, 0, 0, (),
+          "The Scheme specified on command-line with @samp{-d}.")
+{
+  return ly_string2scm (init_scheme_variables_global); 
+}
+
+LY_DEFINE (ly_command_line_code, "ly:command-line-code", 0, 0, 0, (),
+          "The Scheme specified on command-line with @samp{-e}.")
+{
+  return ly_string2scm (init_scheme_code_string_global); 
+}
+
 LY_DEFINE (ly_command_line_verbose_p, "ly:command-line-verbose?", 0, 0, 0, (),
           "Was be_verbose_global set?")
 {
index 1ee840aa0bad03eaa939cdad2a074fabb67c475b..8edfd9c757f33365f1fcf65ba9d5d0f2665ffb51 100644 (file)
@@ -68,3 +68,4 @@
        ly:beam::quanting
        (check-beam-slope-sign comparison)      
        ))
+
index d4e05a4af1a9b1c20c08a32428b1e7baa3eaef2b..e10b4b7d3374b4d687ed282ea1988fcec87b012d 100644 (file)
 ;; Abbrv-PWR!
 (defmacro-public _i (x) x)
 
+(read-enable 'positions)
+(debug-enable 'debug)
+
+
 (define (define-scheme-options)
   (for-each (lambda (x)
              (ly:add-option (car x) (cadr x) (caddr x)))
@@ -72,7 +76,12 @@ on errors, and print a stack trace.")
              (show-available-fonts #f
                                    "List font names available.")
              (verbose ,(ly:command-line-verbose?) "value for the --verbose flag")
-             )))
+             ))
+
+  (map
+   (lambda (x)
+     (ly:set-option (car x) (cdr x))) 
+   (eval-string (ly:command-line-options))))
 
 
 ;; need to do this in the beginning. Other parts of the
@@ -80,6 +89,8 @@ on errors, and print a stack trace.")
 ;;
 (define-scheme-options)
 
+
+
 (debug-set! stack 0)
 
 (if (defined? 'set-debug-cell-accesses!)
@@ -265,9 +276,10 @@ The syntax is the same as `define*-public'."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; other files.
 
-(for-each ly:load
-         ;; load-from-path
-         '("lily-library.scm"
+
+(define
+  init-scheme-files
+  '("lily-library.scm"
            "file-cache.scm"
            "define-event-classes.scm"
            "define-music-types.scm"
@@ -314,6 +326,11 @@ The syntax is the same as `define*-public'."
            "safe-lily.scm"))
 
 
+
+
+(for-each ly:load init-scheme-files)
+
+
 (set! type-p-name-alist
       `(
        (,boolean-or-symbol? . "boolean or symbol")
@@ -482,11 +499,13 @@ The syntax is the same as `define*-public'."
 
 (define-public (lilypond-main files)
   "Entry point for LilyPond."
-  
+
   (define (no-files-handler)
     (ly:usage)
     (exit 2))
 
+  (eval-string (ly:command-line-code))
+  
   (if (ly:get-option 'gui)
       (gui-main files))
 
@@ -561,6 +580,7 @@ The syntax is the same as `define*-public'."
           
   (if (string-or-symbol? (ly:get-option 'log-file))
       (ly:stderr-redirect (format "~a.log" (ly:get-option 'log-file)) "w"))
+
   
   (let ((failed (lilypond-all files)))
     (if (pair? failed)
@@ -573,7 +593,7 @@ The syntax is the same as `define*-public'."
          (exit 0)))))
 
 (define-public (lilypond-all files)
-
+  
 
   (if (ly:get-option 'show-available-fonts)
       (begin
@@ -631,7 +651,7 @@ The syntax is the same as `define*-public'."
 
     (if (ly:get-option 'dump-profile)
        (dump-profile "lily-run-total" '(0 0) (profile-measurements)))
-    
+
     failed))
 
 (define (lilypond-file handler file-name)