X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lily%2Fprogram-option.cc;h=215bcfe0b9cee0abdde5c2e1e9df83090be36685;hb=cd97f3fa5b1275595307e89b5b070f833adb573a;hp=cd3b857818ed6e9416917ccce4136b9d775a8347;hpb=f803dfe5c67d7a51f3b9b347f41fe43005963810;p=lilypond.git diff --git a/lily/program-option.cc b/lily/program-option.cc index cd3b857818..215bcfe0b9 100644 --- a/lily/program-option.cc +++ b/lily/program-option.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 2001--2005 Han-Wen Nienhuys + (c) 2001--2006 Han-Wen Nienhuys */ #include "program-option.hh" @@ -12,10 +12,11 @@ #include using namespace std; -#include "string-convert.hh" +#include "international.hh" +#include "main.hh" #include "parse-scm.hh" +#include "string-convert.hh" #include "warn.hh" -#include "main.hh" /* Write midi as formatted ascii stream? */ bool do_midi_debugging_global; @@ -31,6 +32,8 @@ bool profile_property_accesses = false; crash if internally the wrong type is used for a grob property. */ bool do_internal_type_checking_global; +bool strict_infinity_checking = false; + static SCM option_hash; @@ -77,28 +80,33 @@ void internal_set_option (SCM var, SCM val) use_object_keys = to_boolean (val); val = scm_from_bool (to_boolean (val)); } + else if (var == ly_symbol2scm ("strict-infinity-checking")) + { + strict_infinity_checking = to_boolean (val); + val = scm_from_bool (to_boolean (val)); + } } -const int HELP_INDENT = 30; -const int INDENT = 2; -const int SEPARATION = 5; +ssize const HELP_INDENT = 30; +ssize const INDENT = 2; +ssize const SEPARATION = 5; /* Hmmm. should do in SCM / C++ ? */ -static String +static string get_help_string () { SCM alist = ly_hash2alist (option_hash); SCM convertor = ly_lily_module_constant ("scm->string"); - Array opts; + vector opts; for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s)) { SCM sym = scm_caar (s); SCM val = scm_cdar (s); - String opt_spec + string opt_spec = String_convert::char_string (' ', INDENT) + ly_symbol2string (sym) + " (" @@ -115,28 +123,29 @@ get_help_string () SCM opt_help_scm = scm_object_property (sym, ly_symbol2scm ("program-option-documentation")); - String opt_help = ly_scm2string (opt_help_scm); - opt_help.substitute (String ("\n"), - String ("\n") - + String_convert::char_string (' ', HELP_INDENT)); + string opt_help = ly_scm2string (opt_help_scm); + replace_all (opt_help, + string ("\n"), + string ("\n") + + String_convert::char_string (' ', HELP_INDENT)); - opts.push (opt_spec + opt_help + "\n"); + opts.push_back (opt_spec + opt_help + "\n"); } - String help ("Options supported by ly:set-option\n\n"); - opts.sort (String::compare); - for (int i = 0; i < opts.size (); i++) + string help ("Options supported by ly:set-option\n\n"); + vector_sort (opts, string_compare); + for (vsize i = 0; i < opts.size (); i++) help += opts[i]; - help += String ("\n"); + help += string ("\n"); return help; } LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 0, 0, (), "Print ly:set-option usage") { - String help = get_help_string (); - fputs (help.to_str0 (), stdout); + string help = get_help_string (); + fputs (help.c_str (), stdout); exit (0); return SCM_UNSPECIFIED; @@ -174,16 +183,16 @@ LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val), if (val == SCM_UNDEFINED) val = SCM_BOOL_T; - String varstr = ly_scm2string (scm_symbol_to_string (var)); - if (varstr.left_string (3) == String ("no-")) + string varstr = ly_scm2string (scm_symbol_to_string (var)); + if (varstr.substr (0, 3) == string ("no-")) { - var = ly_symbol2scm (varstr.nomid_string (0, 3).to_str0 ()); + var = ly_symbol2scm (varstr.substr (3, varstr.length () -3).c_str ()); val = scm_from_bool (!to_boolean (val)); } SCM handle = scm_hashq_get_handle (option_hash, var); if (handle == SCM_BOOL_F) - warning (_f ("no such internal option: %s", varstr.to_str0 ())); + warning (_f ("no such internal option: %s", varstr.c_str ())); internal_set_option (var, val); return SCM_UNSPECIFIED;