]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/main.cc
*** empty log message ***
[lilypond.git] / lily / main.cc
index a53db5bc9883a494f590191e0241bfdc201c0330..b104b899915b1da3ea58be58b08fcb4d3dd30741 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include <stdlib.h>
@@ -26,7 +26,7 @@
 #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"
@@ -103,11 +103,11 @@ static Getopt_long *oparser_p_static = 0;
        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")},
+  {_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")},
@@ -185,7 +185,7 @@ version ()
     "lilypond").to_str0 ());
   printf ("\n");
 
-  printf (_f ("Copyright (c) %s by", "1996--2002").to_str0 ());
+  printf (_f ("Copyright (c) %s by", "1996--2003").to_str0 ());
   printf ("\n");
   printf ("  Han-Wen Nienhuys <hanwen@cs.uu.nl>\n");
   printf ("  Jan Nieuwenhuizen <janneke@gnu.org>\n");
@@ -197,7 +197,7 @@ notice ()
   printf ("\n");
   printf (_ ("GNU LilyPond -- The music typesetter").to_str0 ());
   printf ("\n");
-  printf (_f ("Copyright (c) %s by", "1996--2002").to_str0 ());
+  printf (_f ("Copyright (c) %s by", "1996--2003").to_str0 ());
   printf ("\n");
   printf ("  Han-Wen Nienhuys <hanwen@cs.uu.nl>\n");
   printf ("  Jan Nieuwenhuizen <janneke@gnu.org>\n");
@@ -222,7 +222,7 @@ notice ()
 /* Where LilyPond's init files live.  Typically:
    LILYPOND_DATADIR = /usr/local/share/lilypond
    LOCAL_LILYPOND_DATADIR = /usr/local/share/lilypond/1.5.68 */
-char const *prefix_directory[2] = {LILYPOND_DATADIR, LOCAL_LILYPOND_DATADIR};
+char const *prefix_directory[] = {LILYPOND_DATADIR, LOCAL_LILYPOND_DATADIR, 0};
 
 void
 setup_paths ()
@@ -231,23 +231,14 @@ setup_paths ()
     prefix_directory[1] = lilypond_prefix;
 
 #if HAVE_GETTEXT
-  setlocale (LC_ALL, ""); /* enable locales */
-  setlocale (LC_NUMERIC, "C"); /* musn't have comma's in TeX output... */
+  /* Enable locales */
+  setlocale (LC_ALL, "");
+  /* Mustn't have commas in TeX output... */
+  setlocale (LC_NUMERIC, "C");
   String lily_locale_dir;
   String name (PACKAGE);
   name.to_lower ();
-
-  /*
-    urg; what *do* we want with $LILYPONDPREFIX, DIR_DATADIR and $prefix/share
-    handy for multiple source-dir runs, though...
-   */
-  if (!String (prefix_directory[0]).empty_b ())
-    {
-      lily_locale_dir = String (prefix_directory[0]) + "/share/locale";
-      bindtextdomain (name.to_str0 (), lily_locale_dir.to_str0 ());
-    }
-  else
-    bindtextdomain (name.to_str0 (), LOCALEDIR);
+  bindtextdomain (name.to_str0 (), LOCALEDIR);
   textdomain (name.to_str0 ());
 #endif
 
@@ -258,12 +249,11 @@ setup_paths ()
      LILYPONDPREFIX to lilypond-x.y.z */
   char *suffixes[] = {"ly", "afm", "mf/out", "scm", "tfm", "ps", 0};
 
-  for (unsigned i = 0; i < sizeof (prefix_directory)
-        / sizeof (*prefix_directory); i++)
+  for (unsigned i = 0; prefix_directory[i]; i++)
     for (char **s = suffixes; *s; s++)
       {
        String p = prefix_directory[i] + to_string ('/') + String (*s);
-       global_path.add (p);
+       global_path.prepend (p);
        
 #if !KPATHSEA
        /* Urg: GNU make's $ (word) index starts at 1 */
@@ -289,7 +279,7 @@ distill_inname (String str)
   else
     {
       String orig_ext = p.ext;
-      char const *extensions[] = {"ly", "fly", "sly", "", 0};
+      char const *extensions[] = {"ly", "", 0};
       for (int i = 0; extensions[i]; i++)
        {
          p.ext = orig_ext;
@@ -329,10 +319,10 @@ main_prog (void *, int, char **)
   /* Engravers use lily.scm contents, need to make Guile find it.
      Prepend onto GUILE %load-path, very ugh. */
      
-  for (unsigned i = 0; i < sizeof (prefix_directory)
-        / sizeof (*prefix_directory); i++)
+  for (unsigned i = 0; prefix_directory[i]; i++)
     {
       prepend_load_path (prefix_directory[i]);
+
       /* Junk this.  We should make real modules iso. just loading files. */
       prepend_load_path (String (prefix_directory[i]) + "/scm");
     }
@@ -341,10 +331,10 @@ main_prog (void *, int, char **)
     dirinfo (stderr);
   
   ly_init_guile ();
+  call_constructors ();
 
-  printf ("\n");
+  progress_indication ("\n");
 
-  call_constructors ();
   all_fonts_global = new All_font_metrics (global_path.string ());
 
   init_scheme_code_string += ")";
@@ -352,7 +342,17 @@ main_prog (void *, int, char **)
   
   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);
@@ -377,8 +377,6 @@ main_prog (void *, int, char **)
       String init;
       if (!init_name_global.empty_b ())
        init = init_name_global;
-      else if (!inpath.ext.empty_b ())
-       init = "init." + inpath.ext;
       else
        init = "init.ly";
        
@@ -505,14 +503,6 @@ main (int argc, char **argv)
       exit (0);
     }
 
-
-  if (!oparser_p_static->current_arg () )
-    {
-      usage ();
-      /* No FILE arguments is now a usage error */
-      exit (2);
-    }
-
   scm_boot_guile (argc, argv, (void (*) (void*, int, char**))main_prog, 0);
 
   return 0;                    // unreachable