#include <stdio.h>
#include <assert.h>
#include <locale.h>
-#include <stdio.h>
-
-#include <iostream>
+#include <string.h>
#include "config.h"
#include "string.hh"
#include "main.hh"
#include "file-path.hh"
-#include "file-results.hh"
+#include "input-file-results.hh"
#include "warn.hh"
#include "lily-guile.hh"
#include "paper-def.hh"
*/
-All_font_metrics *all_fonts_global_p;
+All_font_metrics *all_fonts_global;
int exit_status_global;
File_path global_path;
follow regular localisation guidelines).
*/
static Long_option_init options_static[] = {
- /* print example usage: lilypond -e "" ? */
- {_i ("EXPR"), "evaluate", 'e',_i ("Scheme options: try -e \"(set-lily-option 'help 0)\" for more help.")},
+ {_i ("EXPR"), "evaluate", 'e',
+ _i ("set options, use -e '(ly-option-usage)' for help")},
/* another bug in option parser: --output=foe is taken as an abbreviation
for --output-format */
- {_i ("EXT"), "format", 'f', _i ("use output format EXT (tex [default], pdftex, ps, scm or as)")},
+ {_i ("EXT"), "format", 'f', _i ("use output format EXT")},
{0, "help", 'h', _i ("this help")},
{_i ("FIELD"), "header", 'H', _i ("write header field to BASENAME.FIELD")},
{_i ("DIR"), "include", 'I', _i ("add DIR to search path")},
void
identify (FILE *out)
{
- fputs (gnu_lilypond_version_str ().ch_C (), out);
+ fputs (gnu_lilypond_version_string ().to_str0 (), out);
}
void
void
usage ()
{
- std::cout << "\n";
+ printf ("\n");
/* No version number or newline here. It confuses help2man. */
- std::cout << _f ("Usage: %s [OPTION]... FILE...", "lilypond").ch_C ();
- std::cout << "\n\n";
- std::cout << _ ("Typeset music and or play MIDI from FILE").ch_C ();
- std::cout << "\n\n";
- std::cout <<
-_ (
+ printf (_f ("Usage: %s [OPTION]... FILE...", "lilypond").to_str0 ());
+ printf ("\n\n");
+ printf (_ ("Typeset music and or play MIDI from FILE").to_str0 ());
+ printf ("\n\n");
+ printf(_ (
"LilyPond is a music typesetter. It produces beautiful sheet music\n"
"using a high level description file as input. LilyPond is part of \n"
"the GNU Project.\n"
-).ch_C ();
+).to_str0 ());
- std::cout << '\n';
- std::cout << _ ("Options:").ch_C ();
- std::cout << '\n';
- std::cout << Long_option_init::table_str (options_static).ch_C ();
- std::cout << '\n';
- std::cout << std::endl;
+ printf ("\n");
+ printf (_ ("Options:").to_str0 ());
+ printf ("\n");
+ printf (Long_option_init::table_string (options_static).to_str0 ());
+ printf ("\n");
+ printf ("\n");
- std::cout << _f ("Report bugs to %s", "bug-lilypond@gnu.org").ch_C () << std::endl;
+ printf (_f ("Report bugs to %s", "bug-lilypond@gnu.org").to_str0 ());
+ printf ("\n");
}
void
version ()
{
identify (stdout);
- std::cout << '\n';
- std::cout << _f (""
+ printf ("\n");
+ printf (_f (
"This is free software. It is covered by the GNU General Public License,\n"
"and you are welcome to change it and/or distribute copies of it under\n"
"certain conditions. Invoke as `%s --warranty' for more information.\n",
- "lilypond").ch_C ();
- std::cout << std::endl;
+ "lilypond").to_str0 ());
+ printf ("\n");
- std::cout << _f ("Copyright (c) %s by", "1996--2002").ch_C ();
- std::cout << '\n';
- std::cout << " Han-Wen Nienhuys <hanwen@cs.uu.nl>\n";
- std::cout << " Jan Nieuwenhuizen <janneke@gnu.org>\n";
+ printf (_f ("Copyright (c) %s by", "1996--2002").to_str0 ());
+ printf ("\n");
+ printf (" Han-Wen Nienhuys <hanwen@cs.uu.nl>\n");
+ printf (" Jan Nieuwenhuizen <janneke@gnu.org>\n");
}
void
notice ()
{
- std::cout << '\n';
- std::cout << _ ("GNU LilyPond -- The music typesetter").ch_C ();
- std::cout << '\n';
- std::cout << _f ("Copyright (c) %s by", "1996--2002").ch_C ();
- std::cout << '\n';
- std::cout << " Han-Wen Nienhuys <hanwen@cs.uu.nl>\n";
- std::cout << " Jan Nieuwenhuizen <janneke@gnu.org>\n";
- std::cout << '\n';
- std::cout << _ (
+ printf ("\n");
+ printf (_ ("GNU LilyPond -- The music typesetter").to_str0 ());
+ printf ("\n");
+ printf (_f ("Copyright (c) %s by", "1996--2002").to_str0 ());
+ printf ("\n");
+ printf (" Han-Wen Nienhuys <hanwen@cs.uu.nl>\n");
+ printf (" Jan Nieuwenhuizen <janneke@gnu.org>\n");
+ printf ("\n");
+ printf ( _ (
" This program is free software; you can redistribute it and/or\n"
"modify it under the terms of the GNU General Public License version 2\n"
"as published by the Free Software Foundation.\n"
" You should have received a copy (refer to the file COPYING) of the\n"
"GNU General Public License along with this program; if not, write to\n"
"the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
- "USA.\n").ch_C ();
+ "USA.\n").to_str0 ());
}
if (!String (prefix_directory[0]).empty_b ())
{
lily_locale_dir = String (prefix_directory[0]) + "/share/locale";
- bindtextdomain (name.ch_C (), lily_locale_dir.ch_C ());
+ bindtextdomain (name.to_str0 (), lily_locale_dir.to_str0 ());
}
else
- bindtextdomain (name.ch_C (), LOCALEDIR);
- textdomain (name.ch_C ());
+ bindtextdomain (name.to_str0 (), LOCALEDIR);
+ textdomain (name.to_str0 ());
#endif
global_path.add ("");
/ sizeof (*prefix_directory); i++)
for (char **s = suffixes; *s; s++)
{
- String p = prefix_directory[i] + to_str ('/') + String (*s);
- global_path.add (p);
+ String p = prefix_directory[i] + to_string ('/') + String (*s);
+ global_path.prepend (p);
#if !KPATHSEA
/* Urg: GNU make's $ (word) index starts at 1 */
int i = 1;
- while (global_path.try_add (p + to_str (".") + to_str (i)))
+ while (global_path.try_add (p + to_string (".") + to_string (i)))
i++;
#endif
}
if (*extensions[i] && !p.ext.empty_b ())
p.ext += ".";
p.ext += extensions[i];
- if (!global_path.find (p.str ()).empty_b ())
+ if (!global_path.find (p.string ()).empty_b ())
break;
}
/* Reshuffle extension */
- p = split_path (p.str ());
+ p = split_path (p.string ());
}
return p;
}
String s = "(set! %load-path (cons \""
+ dir
+ "\" %load-path))";
- scm_c_eval_string (s.ch_C ());
+ scm_c_eval_string (s.to_str0 ());
}
void
/* Junk this. We should make real modules iso. just loading files. */
prepend_load_path (String (prefix_directory[i]) + "/scm");
}
-
+
if (verbose_global_b)
dirinfo (stderr);
ly_init_guile ();
-
- std::cout << std::endl;
+
+ progress_indication ("\n");
call_constructors ();
- all_fonts_global_p = new All_font_metrics (global_path.str ());
+ all_fonts_global = new All_font_metrics (global_path.string ());
init_scheme_code_string += ")";
- gh_eval_str ((char *)init_scheme_code_string.ch_C ());
+ gh_eval_str ((char *)init_scheme_code_string.to_str0 ());
int p=0;
const char *arg = oparser_p_static->get_next_arg ();
+ /* Only exit until after running init_scheme_code, for
+ (ly-option-usage) or
+ -e "(ly-set-option 'help #t)" */
if (!arg)
{
usage ();
/* No FILE arguments is now a usage error */
exit (2);
}
-
+
do
{
String infile (arg);
/* By default, use base name of input file for output file name */
Path outpath = inpath;
- if (inpath.str () != "-")
+ if (inpath.string () != "-")
outpath.ext = format_to_ext (output_format_global);
/* By default, write output to cwd; do not copy directory part
/* Burp: output name communication goes through _global */
String save_output_name_global = output_name_global;
- output_name_global = outpath.str ();
- do_one_file (init, inpath.str ());
+ output_name_global = outpath.string ();
+ do_one_file (init, inpath.string ());
output_name_global = save_output_name_global;
p++;
sane_putenv (char const* key, char const* value, bool overwrite)
{
if (overwrite || !getenv (key))
- return putenv ((char*)((String (key) + "=" + value).ch_C ()));
+ {
+ String combine = String (key) + "=" + String (value);
+ char * s = strdup(combine.to_str0 ());
+ return putenv (s);
+ }
return -1;
}
{
setup_paths ();
- /* Prepare GUILE for heavy memory usage. If you have plenty memory,
- this may speed up GUILE a bit. If you're short on memory, these
- settings
+ /*
- export GUILE_INIT_SEGMENT_SIZE_1=36000
- export GUILE_MAX_SEGMENT_SIZE=576000
+ These settings hopefully prepare lily for a lot of memory usage.
- may considerably decrease memory footprint (~*0.85), with a small
- execution time penalty (~*1.10). However, if this 15% gain in memory
- usage prevents swapping, the execution time falls drastically. */
-
+ In practice the effect on GC times is barely measurable -- larger
+ segments cost slighly less time for the conservative marking. (but
+ not impressively much)
+
+ */
sane_putenv ("GUILE_INIT_SEGMENT_SIZE_1", "4194304", false);
sane_putenv ("GUILE_MAX_SEGMENT_SIZE", "8388608", false);
oparser_p_static = new Getopt_long (argc, argv, options_static);
while (Long_option_init const * opt = (*oparser_p_static) ())
{
- switch (opt->shortname_ch_)
+ switch (opt->shortname_char_)
{
case 'v':
version ();
break;
case 'o':
{
- String s = oparser_p_static->optional_argument_ch_C_;
+ String s = oparser_p_static->optional_argument_str0_;
Path p = split_path (s);
if (s != "-" && p.ext.empty_b ())
p.ext = format_to_ext (output_format_global);
- output_name_global = p.str ();
+ output_name_global = p.string ();
}
break;
case 'e':
init_scheme_code_string +=
- oparser_p_static->optional_argument_ch_C_;
+ oparser_p_static->optional_argument_str0_;
break;
case 'w':
notice ();
exit (0);
break;
case 'f':
- output_format_global = oparser_p_static->optional_argument_ch_C_;
+ if (oparser_p_static->optional_argument_str0_ == "help")
+ {
+ printf("See http://lilypond.org/wiki?OutputFormats for more information.\n"\
+ "This option is for developers only.\n");
+ exit (0);
+ }
+ output_format_global = oparser_p_static->optional_argument_str0_;
break;
case 'P':
- dependency_prefix_global = oparser_p_static->optional_argument_ch_C_;
+ dependency_prefix_global = oparser_p_static->optional_argument_str0_;
break;
case 'H':
- dump_header_fieldnames_global.push (oparser_p_static->optional_argument_ch_C_);
+ dump_header_fieldnames_global.push (oparser_p_static->optional_argument_str0_);
break;
case 'I':
- global_path.push (oparser_p_static->optional_argument_ch_C_);
+ global_path.push (oparser_p_static->optional_argument_str0_);
break;
case 'i':
- init_name_global = oparser_p_static->optional_argument_ch_C_;
+ init_name_global = oparser_p_static->optional_argument_str0_;
break;
case 'h':
help_b = true;
exit (0);
}
-#ifdef WINNT
- scm_boot_guile (argc, argv, main_prog, 0);
-#else
scm_boot_guile (argc, argv, (void (*) (void*, int, char**))main_prog, 0);
-#endif
return 0; // unreachable
}
-
-