]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/main.cc
release: 0.1.7
[lilypond.git] / lily / main.cc
index d14272f41b2d500755d4613104ca64e81ed0c7ad..eff3d6cc811f3244dd57a039a9284ffb18264adc 100644 (file)
@@ -1,7 +1,7 @@
 /*
   main.cc -- implement main: entrypoints
 
-  source file of the LilyPond music typesetter
+  source file of the GNU LilyPond music typesetter
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 #include "path.hh"
 #include "config.hh"
 #include "source.hh"
+#include "debug.hh"
 #include "my-lily-parser.hh"
 
 Sources* source_l_g = 0;
 bool only_midi = false;
 bool version_ignore_b_ = false;
+int exit_status_i_;
 
 void destill_inname( String &name_str_r);
 
@@ -54,7 +56,7 @@ usage()
        "  -M, --midi             produce midi output only\n"
        "  -V, --ignore-version   ignore mudela version\n"
        "\n"
-       "LilyPond was compiled with the following settings:\n"
+       "GNU LilyPond was compiled with the following settings:\n"
 #ifdef NDEBUG
        "NDEBUG "       
 #endif
@@ -64,7 +66,10 @@ usage()
 #ifdef STRING_UTILS_INLINED
        "STRING_UTILS_INLINED "
 #endif
-       "datadir= " DIR_DATADIR "\n" 
+       "datadir= " DIR_DATADIR 
+
+       "\n";
+       
        ;
     
     
@@ -75,12 +80,10 @@ notice()
 {
     cout <<
        "\n"
-       "LilyPond, a music typesetter.\n"
-       "Copyright (C) 1996,97 by\n"
+       "GNU LilyPond -- The GNU Project music typesetter.\n"
+       "Copyright 1996,97 by\n"
        "  Han-Wen Nienhuys <hanwen@stack.nl>\n"
        "  Jan Nieuwenhuizen <jan@digicash.com>\n"
-       "Contributors\n"
-       "  Mats Bengtsson <matsb@s3.kth.se>\n"
        "\n"
        "    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"
@@ -97,14 +100,24 @@ notice()
        "USA.\n";
 }
 
-static File_path * path_l =0;
+
+static File_path path;
 
 void
 do_one_file(String init_str, String file_str)
 {
+    if ( init_str != "" && "" == path.find( init_str ) ) {
+       error ( "Can not find `" + init_str +"\'");
+       return ;
+    }
+    if ( file_str!= "" && path.find( file_str ) == "" ) {
+       error ( "Can not find `" + file_str + "'");
+       return ;
+    }
+    
     Sources sources;
     source_l_g = &sources; 
-    source_l_g->set_path(path_l);
+    source_l_g->set_path(&path);
     {
        My_lily_parser parser(source_l_g);
        parser.set_version_check(version_ignore_b_);
@@ -118,40 +131,43 @@ int
 main (int argc, char **argv)
 {    
     debug_init();              // should be first
-    File_path path(String(DIR_DATADIR)+"/init/") ;
-    path_l = & path;
-    path_l->push(DIR_DATADIR );
 
+
+    // must override (come before) "/usr/local/share/lilypond"!
     char const * env_l=getenv("LILYINCLUDE");
     if (env_l) {
        path.add(env_l);
     }
+    path.add( "" );
+    path.add( String( DIR_DATADIR ) + "/init/" );
     
+    path.push(DIR_DATADIR );
+
     Getopt_long oparser(argc, argv,theopts);
     cout << get_version_str() << endl;
-    String init_str("symbol.ini");
+    String init_str("symbol.ly");
     
-    while (Long_option_init * opt = oparser()) {
+    while (Long_option_init const * opt = oparser()) {
        switch ( opt->shortname){
        case 'o':
-           set_default_output(oparser.optarg);
+           set_default_output(oparser.optional_argument_ch_C_);
            break;
        case 'w':
            notice();
            exit(0);
            break;
        case 'I':
-           path.push(oparser.optarg);
+           path.push(oparser.optional_argument_ch_C_);
            break;
        case 'i':
-           init_str = oparser.optarg;
+           init_str = oparser.optional_argument_ch_C_;
            break;
        case 'h':
            usage();
            exit(0);
            break;
        case 'V':
-           version_ignore_b_ = false;
+           version_ignore_b_ = true;
            break;
        case 'd':
            set_debug(true);
@@ -166,7 +182,7 @@ main (int argc, char **argv)
     }
 
     int p=0;
-    char *arg ;
+    const char *arg ;
     while ( (arg= oparser.get_next_arg()) ) {
        String f(arg);
        destill_inname(f);
@@ -177,7 +193,7 @@ main (int argc, char **argv)
        do_one_file(init_str, "");      
     }
 
-    return 0;
+    return exit_status_i_;
 }
 
 /// make input file name: add default extension. "" is stdin.