]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/program-option-scheme.cc
Run grand-replace (issue 3765)
[lilypond.git] / lily / program-option-scheme.cc
index 86c57226d1ed734abe32c4431bac40db656bdefd..71538d69e699eed04babfbcd3d44fac8e710e019 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2001--2009  Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 2001--2014  Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -34,13 +34,9 @@ bool debug_skylines;
 bool debug_property_callbacks;
 bool debug_page_breaking_scoring;
 
+bool music_strings_to_paths;
 bool relative_includes;
 
-/*
-  Backwards compatibility.
-*/
-bool lily_1_8_relative = false;
-bool lily_1_8_compatibility_used = false;
 bool profile_property_accesses = false;
 /*
   crash if internally the wrong type is used for a grob property.
@@ -50,87 +46,85 @@ bool strict_infinity_checking = false;
 
 static SCM option_hash;
 
-
 void
 internal_set_option (SCM var,
-                    SCM val)
+                     SCM val)
 {
+  string varstr = robust_symbol2string (var, "");
+  bool valbool = to_boolean (val);
+  SCM val_scm_bool = scm_from_bool (valbool);
   if (0)
     ;
-  else if (var == ly_symbol2scm ("profile-property-accesses"))
+  else if (varstr == "profile-property-accesses")
     {
-      profile_property_accesses = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
+      profile_property_accesses = valbool;
+      val = val_scm_bool;
     }
-  else if (var == ly_symbol2scm ("point-and-click"))
+  else if (varstr == "protected-scheme-parsing")
     {
-      point_and_click_global = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
+      parse_protect_global = valbool;
+      val = val_scm_bool;
     }
-  else if (var == ly_symbol2scm ("protected-scheme-parsing"))
+  else if (varstr == "check-internal-types")
     {
-      parse_protect_global = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
+      do_internal_type_checking_global = valbool;
+      val = val_scm_bool;
     }
-  else if (var == ly_symbol2scm ("check-internal-types"))
+  else if (varstr == "debug-gc-assert-parsed-dead")
     {
-      do_internal_type_checking_global = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
+      parsed_objects_should_be_dead = valbool;
+      val = val_scm_bool;
     }
-  else if (var == ly_symbol2scm ("debug-gc-assert-parsed-dead"))
+  else if (varstr == "safe")
     {
-      parsed_objects_should_be_dead = to_boolean (val);
-      val = scm_from_bool (parsed_objects_should_be_dead);
+      be_safe_global = valbool;
+      val = val_scm_bool;
     }
-  else if (var == ly_symbol2scm ("safe"))
+  else if (varstr == "strict-infinity-checking")
     {
-      be_safe_global = to_boolean (val);
-      val = scm_from_bool (be_safe_global);
+      strict_infinity_checking = valbool;
+      val = val_scm_bool;
     }
-  else if (var == ly_symbol2scm ("old-relative"))
+  else if (varstr == "debug-skylines")
     {
-      lily_1_8_relative = to_boolean (val);
-      /* Needs to be reset for each file that uses this option. */
-      lily_1_8_compatibility_used = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
+      debug_skylines = valbool;
+      val = val_scm_bool;
     }
-  else if (var == ly_symbol2scm ("strict-infinity-checking"))
+  else if (varstr == "debug-property-callbacks")
     {
-      strict_infinity_checking = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
+      debug_property_callbacks = valbool;
+      val = val_scm_bool;
     }
-  else if (var == ly_symbol2scm ("debug-skylines"))
+  else if (varstr == "debug-page-breaking-scoring")
     {
-      debug_skylines = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
+      debug_page_breaking_scoring = valbool;
+      val = val_scm_bool;
     }
-  else if (var == ly_symbol2scm ("debug-property-callbacks"))
+  else if (varstr == "datadir")
     {
-      debug_property_callbacks = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
+      /* ignore input value. */
+      val = ly_string2scm (lilypond_datadir);
     }
-  else if (var == ly_symbol2scm ("debug-page-breaking-scoring"))
+  else if (varstr == "relative-includes")
     {
-      debug_page_breaking_scoring = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
+      relative_includes = valbool;
+      val = val_scm_bool;
     }
-  else if (var == ly_symbol2scm ("datadir"))
+  else if (varstr == "warning-as-error")
     {
-      /* ignore input value. */
-      val = ly_string2scm (lilypond_datadir);
+      /* warning_as_error is defined in flower/warn.cc */
+      warning_as_error = valbool;
+      val = val_scm_bool;
     }
-  else if (var == ly_symbol2scm ("relative-includes"))
+  else if (varstr == "music-strings-to-paths")
     {
-      relative_includes = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
+      music_strings_to_paths = valbool;
+      val = val_scm_bool;
     }
-  else if (var == ly_symbol2scm ("warning-as-error"))
-    val = scm_from_bool (to_boolean (val));
 
   scm_hashq_set_x (option_hash, var, val);
 }
 
-
 ssize const HELP_INDENT = 30;
 ssize const INDENT = 2;
 ssize const SEPARATION = 5;
@@ -151,25 +145,25 @@ get_help_string ()
       SCM sym = scm_caar (s);
       SCM val = scm_cdar (s);
       string opt_spec = String_convert::char_string (' ', INDENT)
-                       + ly_symbol2string (sym)
-                       + " ("
-                       + ly_scm2string (scm_call_1 (converter, val))
-                       + ")";
+                        + ly_symbol2string (sym)
+                        + " ("
+                        + ly_scm2string (scm_call_1 (converter, val))
+                        + ")";
 
       if (opt_spec.length () + SEPARATION > HELP_INDENT)
-       opt_spec += "\n" + String_convert::char_string (' ', HELP_INDENT);
+        opt_spec += "\n" + String_convert::char_string (' ', HELP_INDENT);
       else
-       opt_spec += String_convert::char_string (' ', HELP_INDENT
-                                                     - opt_spec.length ());
+        opt_spec += String_convert::char_string (' ', HELP_INDENT
+                                                 - opt_spec.length ());
 
       SCM opt_help_scm
-       = scm_object_property (sym,
-                              ly_symbol2scm ("program-option-documentation"));
+        = scm_object_property (sym,
+                               ly_symbol2scm ("program-option-documentation"));
       string opt_help = ly_scm2string (opt_help_scm);
       replace_all (&opt_help,
-                  string ("\n"),
-                  string ("\n")
-                  + String_convert::char_string (' ', HELP_INDENT));
+                   string ("\n"),
+                   string ("\n")
+                   + String_convert::char_string (' ', HELP_INDENT));
 
       opts.push_back (opt_spec + opt_help + "\n");
     }
@@ -181,21 +175,20 @@ get_help_string ()
   return help;
 }
 
-
-LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 0, 0, (),
-          "Print @code{ly:set-option} usage.")
+LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 1, 0, (SCM port),
+           "Print @code{ly:set-option} usage.  Optional @var{port} argument"
+           "for the destination defaults to current output port.")
 {
-  string help = get_help_string ();
-  puts (help.c_str());
+  SCM str = scm_from_locale_string (get_help_string ().c_str ());
+  scm_write_line (str, port);
 
   return SCM_UNSPECIFIED;
 }
 
-
 LY_DEFINE (ly_add_option, "ly:add-option", 3, 0, 0,
-          (SCM sym, SCM val, SCM description),
-          "Add a program option @var{sym}.  @var{val} is the default"
-          " value and @var{description} is a string description.")
+           (SCM sym, SCM val, SCM description),
+           "Add a program option @var{sym}.  @var{val} is the default"
+           " value and @var{description} is a string description.")
 {
   if (!option_hash)
     option_hash = scm_permanent_object (scm_c_make_hash_table (11));
@@ -205,21 +198,20 @@ LY_DEFINE (ly_add_option, "ly:add-option", 3, 0, 0,
   internal_set_option (sym, val);
 
   scm_set_object_property_x (sym, ly_symbol2scm ("program-option-documentation"),
-                            description);
+                             description);
 
   return SCM_UNSPECIFIED;
 }
 
-
 LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val),
-          "Set a program option.")
+           "Set a program option.")
 {
   LY_ASSERT_TYPE (ly_is_symbol, var, 1);
 
   if (val == SCM_UNDEFINED)
     val = SCM_BOOL_T;
 
-  string varstr = ly_scm2string (scm_symbol_to_string (var));
+  string varstr = robust_symbol2string (var, "");
   if (varstr.substr (0, 3) == string ("no-"))
     {
       var = ly_symbol2scm (varstr.substr (3, varstr.length () - 3).c_str ());
@@ -234,38 +226,33 @@ 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 options specified on command-line with @option{-d}.")
+           "The Scheme options specified on command-line with @option{-d}.")
 {
   return ly_string2scm (init_scheme_variables_global);
 }
 
-
 LY_DEFINE (ly_command_line_code, "ly:command-line-code", 0, 0, 0, (),
-          "The Scheme code specified on command-line with @option{-e}.")
+           "The Scheme code specified on command-line with @option{-e}.")
 {
   return ly_string2scm (init_scheme_code_global);
 }
 
-
-LY_DEFINE (ly_command_line_verbose_p, "ly:command-line-verbose?", 0, 0, 0, (),
-          "Was @code{be_verbose_global} set?")
+LY_DEFINE (ly_verbose_output_p, "ly:verbose-output?", 0, 0, 0, (),
+           "Was verbose output requested, i.e. loglevel at least @code{DEBUG}?")
 {
-  return scm_from_bool (be_verbose_global);
+  return scm_from_bool (is_loglevel (LOG_DEBUG));
 }
 
-
 LY_DEFINE (ly_all_options, "ly:all-options",
-          0, 0, 0, (),
-          "Get all option settings in an alist.")
+           0, 0, 0, (),
+           "Get all option settings in an alist.")
 {
   return ly_hash2alist (option_hash);
 }
 
-
 LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var),
-          "Get a global option setting.")
+           "Get a global option setting.")
 {
   LY_ASSERT_TYPE (ly_is_symbol, var, 1);
   return scm_hashq_ref (option_hash, var, SCM_BOOL_F);