]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/paper-outputter.cc (output_stencil): New method.
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 27 Apr 2004 16:23:29 +0000 (16:23 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Tue, 27 Apr 2004 16:23:29 +0000 (16:23 +0000)
* lily/my-lily-parser.cc (distill_inname): Remove.

* flower/include/file-name.hh:
* flower/file-name.cc: New file.  Change users.

* flower/file-path.cc [CYGWIN]: Junk testing code.  Remove Path.
(find): New method of same name.

* lily/scm-option.cc (ly:set-option, ly:get-option): Bugfix:
constant error message.

15 files changed:
ChangeLog
flower/file-name.cc [new file with mode: 0644]
flower/file-path.cc
flower/include/file-name.hh [new file with mode: 0644]
flower/include/file-path.hh
flower/include/flower-proto.hh
input/test/blank-paper.ly
lily/include/paper-outputter.hh
lily/main.cc
lily/my-lily-parser.cc
lily/paper-def.cc
lily/paper-outputter.cc
lily/performance.cc
lily/scm-option.cc
scm/lily.scm

index 03c9693c74834c95deb763e1106b5e60df2585df..96f8e7448214f1ec0ae5c5ba6c58f1420f5efb19 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2004-04-27  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * lily/paper-outputter.cc (output_stencil): New method.
+
+       * lily/my-lily-parser.cc (distill_inname): Remove.
+
+       * flower/include/file-name.hh: 
+       * flower/file-name.cc: New file.  Change users.
+
+       * flower/file-path.cc [CYGWIN]: Junk testing code.  Remove Path.
+       (find): New method of same name.
+
+       * lily/scm-option.cc (ly:set-option, ly:get-option): Bugfix:
+       constant error message.
+
 2004-04-27  Heikki Junes <hjunes@cc.hut.fi>
 
        * input/test/{blank-notes.ly,staff-container.ly}: typos.
diff --git a/flower/file-name.cc b/flower/file-name.cc
new file mode 100644 (file)
index 0000000..c265626
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+  file-name.cc - implement File_name
+   
+  source file of the Flower Library
+  
+  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+                 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "config.h"
+#include <stdio.h>
+#include <errno.h>
+#include <limits.h>
+
+#if HAVE_SYS_STAT_H 
+#include <sys/stat.h>
+#endif
+
+#ifdef __CYGWIN__
+#include <sys/cygwin.h>
+#endif
+
+#include "file-name.hh"
+
+/* We don't have multiple roots, set this to '\0'? */
+#ifndef ROOTSEP
+#define ROOTSEP ':'
+#endif
+
+#ifndef DIRSEP
+#define DIRSEP '/'
+#endif
+
+#ifndef EXTSEP
+#define EXTSEP '.'
+#endif
+
+#ifdef __CYGWIN__
+static String
+dos_to_posix (String file_name)
+{
+  char buf[PATH_MAX];
+  char *s = file_name.get_copy_str0 ();
+  /* urg, wtf? char const* argument gets modified! */
+  cygwin_conv_to_posix_path (s, buf);
+  delete s;
+  return buf;
+}
+#endif /* __CYGWIN__ */
+
+/* Join components to full file_name. */
+String
+File_name::to_string () const
+{
+  String s;
+  if (!root_.is_empty ())
+    s = root_ + ::to_string (ROOTSEP);
+  if (!dir_.is_empty ())
+    s += dir_ + ::to_string (DIRSEP);
+  s += base_;
+  if (!ext_.is_empty ())
+    s += ::to_string (EXTSEP) + ext_;
+  return s;
+}
+
+char const*
+File_name::to_str0 () const
+{
+  return to_string ().to_str0 ();
+}
+
+File_name::File_name (String file_name)
+{
+#ifdef __CYGWIN__
+  /* All system functions would work, even if we don't convert to
+     posix file_name, but we'd think that \foe\bar\baz.ly is in the cwd.
+     On by default.  */
+  file_name = dos_to_posix (file_name);
+#endif
+
+  int i = file_name.index (ROOTSEP);
+  if (i >= 0)
+    {
+      root_ = file_name.left_string (i);
+      file_name = file_name.right_string (file_name.length () - i - 1);
+    }
+
+  i = file_name.index_last (DIRSEP);
+  if (i >= 0)
+    {
+      dir_ = file_name.left_string (i);
+      file_name = file_name.right_string (file_name.length () - i - 1);
+    }
+
+  i = file_name.index_last ('.');
+  if (i >= 0)
+    {
+      base_ = file_name.left_string (i);
+      ext_ = file_name.right_string (file_name.length () - i - 1);
+    }
+  else
+    base_ = file_name;
+}
index c59d218cd1f2dce2f4f071cb647005bea0527d7d..c6bd1248aa2dd9be6dd92182148974bbc897ca18 100644 (file)
@@ -1,5 +1,10 @@
 /*
-   path.cc - manipulation of paths and filenames.
+  file-path.cc - implement File_path
+   
+  source file of the Flower Library
+  
+  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+                 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "config.h"
 
 #ifdef __CYGWIN__
 #include <sys/cygwin.h>
-
-// URGURG
-#include "../lily/include/scm-option.hh"
 #endif
 
+#include "file-name.hh"
 #include "file-path.hh"
 
-
 #ifndef PATHSEP
 #define PATHSEP ':'
 #endif
 
-/* We don't have multiple roots, set this to '\0'? */
-#ifndef ROOTSEP
-#define ROOTSEP ':'
-#endif
-
-#ifndef DIRSEP
-#define DIRSEP '/'
-#endif
-
-#ifndef EXTSEP
-#define EXTSEP '.'
-#endif
-
-
-
-#ifdef __CYGWIN__
-static String
-dos_to_posix (String path)
-{
-  char buf[PATH_MAX];
-  char *filename = path.get_copy_str0 ();
-  /* urg, wtf? char const* argument gets modified! */
-  cygwin_conv_to_posix_path (filename, buf);
-  delete filename;
-  return buf;
-}
-
-static String
-dos_to_posix_list (String path)
-{
-  char *filename = path.get_copy_str0 ();
-  int len = cygwin_win32_to_posix_path_list_buf_size (filename);
-  if (len < PATH_MAX)
-    len = PATH_MAX;
-  char *buf = new char[len];
-  /* urg, wtf? char const* argument gets modified! */
-  cygwin_win32_to_posix_path_list (filename, buf);
-  delete filename;
-  
-  String ret = buf;
-  delete buf;
-  return ret;
-}
-#endif /* __CYGWIN__ */
-
-/* Join components to full path. */
-String
-Path::to_string () const
-{
-  String s;
-  if (!root.is_empty ())
-    s = root + ::to_string (ROOTSEP);
-  if (!dir.is_empty ())
-    s += dir + ::to_string (DIRSEP);
-  s += base;
-  if (!ext.is_empty ())
-    s += ::to_string (EXTSEP) + ext;
-  return s;
-}
-
-/**
-   @param path the original full filename
-   @return 4 components of the path. They can be empty
-*/
-Path
-split_path (String path)
-{
-#ifdef __CYGWIN__
-  /* All system functions would work, even if we don't convert to
-     posix path, but we'd think that \foe\bar\baz.ly is in the cwd.
-     On by default.  */
-  if (!(testing_level_global & 1))
-    path = dos_to_posix (path);
-#endif
-
-  Path p;
-  int i = path.index (ROOTSEP);
-  if (i >= 0)
-    {
-      p.root = path.left_string (i);
-      path = path.right_string (path.length () - i - 1);
-    }
-
-  i = path.index_last (DIRSEP);
-  if (i >= 0)
-    {
-      p.dir = path.left_string (i);
-      path = path.right_string (path.length () - i - 1);
-    }
-
-  i = path.index_last ('.');
-  if (i >= 0)
-    {
-      p.base = path.left_string (i);
-      p.ext = path.right_string (path.length () - i - 1);
-    }
-  else
-    p.base = path;
-  return p;
-}
-
 void
 File_path::parse_path (String p)
 {
-#ifdef __CYGWIN__
-  if (testing_level_global & 4)
-    p = dos_to_posix_list (p);
-#endif
-
-  int l;
-  
-  while ((l = p.length ()) )
+  int len;
+  while ((len = p.length ()) )
     {
       int i = p.index (PATHSEP);
       if (i <0) 
-       i = l;
-      add (p.left_string (i));
-      p = p.right_string (l- i - 1);
+       i = len;
+      append (p.left_string (i));
+      p = p.right_string (len - i - 1);
     }
 }
 
-
-
-
 /** Find a file.
-  It will search in the current dir, in the construction-arg, and
-  in any other added path, in this order.
+    
+  Seach in the current dir (DUH! FIXME?), in the construction-arg
+  (what's that?, and in any other appended directory, in this order.
 
   @return
-  The full path if found, or empty string if not found
-  */
+  The file name if found, or empty string if not found. */
+
 String
-File_path::find (String nm) const
+File_path::find (String name) const
 {
-  if (!nm.length () || (nm == "-") )
-    return nm;
-  for (int i=0; i < size (); i++)
+  if (!name.length () || (name == "-") )
+    return name;
+  int n = size ();
+  for (int i = 0; i < n; i++)
     {
-      String path  = elem (i);
+      String file_name = elem (i);
       String sep = ::to_string (DIRSEP);
-      String right (path.right_string (1));
-      if (path.length () && right != sep)
-       path += ::to_string (DIRSEP);
-
-      path += nm;
+      String right (file_name.right_string (1));
+      if (file_name.length () && right != sep)
+       file_name += ::to_string (DIRSEP);
 
+      file_name += name;
 
-#if 0
-      /*
-       Check if directory. TODO: encapsulate for autoconf
-       */
+#if 0 /* Check if directory. TODO: encapsulate for autoconf */
       struct stat sbuf;
-      if (stat (path.to_str0 (), &sbuf) != 0)
+      if (stat (file_name.to_str0 (), &sbuf) != 0)
        continue;
       
       if (! (sbuf.st_mode & __S_IFREG))
@@ -186,59 +76,82 @@ File_path::find (String nm) const
 #if !STAT_MACROS_BROKEN
       
       struct stat sbuf;
-      if (stat (path.to_str0 (), &sbuf) != 0)
+      if (stat (file_name.to_str0 (), &sbuf) != 0)
        continue;
 
       if (S_ISDIR (sbuf.st_mode))
        continue;
 #endif
 
-      FILE *f = fopen (path.to_str0 (), "r"); // ugh!
+      /* ugh */
+      FILE *f = fopen (file_name.to_str0 (), "r");
       if (f)
        {
          fclose (f);
-         return path;
+         return file_name;
        }
     }
   return "";
 }
 
-/**
-   Add a directory, return false if failed
- */
-bool
-File_path::try_add (String s)
-{
-  if (s == "")
-    s =  ".";
-  FILE  * f = fopen (s.to_str0 (), "r");
-  if (!f)
-    return false;
-  fclose (f);
+/** Find a file.
     
-  add (s);
-  return true;
-}
+  Seach in the current dir (DUH! FIXME?), in the construction-arg
+  (what's that?, and in any other appended directory, in this order.
 
-void
-File_path::add (String s)
+  Search for NAME, or name without extension, or name with any of
+  EXTENSIONS, in that order.
+
+  @return
+  The file name if found, or empty string if not found. */
+String
+File_path::find (String name, char const *extensions[])
 {
-#ifdef __CYGWIN__
-  if (testing_level_global & 2)
-    s = dos_to_posix (s);
-#endif
+  File_name file_name (name);
+  if (name.is_empty () || name == "-")
+    file_name.base_ = "-";
+  else
+    {
+      String orig_ext = file_name.ext_;
+      for (int i = 0; extensions[i]; i++)
+       {
+         file_name.ext_ = orig_ext;
+         if (*extensions[i] && !file_name.ext_.is_empty ())
+           file_name.ext_ += ".";
+         file_name.ext_ += extensions[i];
+         if (!find (file_name.to_string ()).is_empty ())
+           break;
+       }
+      /* Reshuffle extension */
+      file_name = File_name (file_name.to_string ());
+    }
+  return file_name.to_string ();
+}
 
-  push (s);
+/** Append a directory, return false if failed.  */
+bool
+File_path::try_append (String s)
+{
+  if (s == "")
+    s =  ".";
+  if (FILE *f = fopen (s.to_str0 (), "r"))
+    {
+      fclose (f);
+      append (s);
+      return true;
+    }
+  return false;
 }
 
 String
 File_path::to_string () const
 {
   String s;
-  for (int i=0; i< size (); i++)
+  int n = size ();
+  for (int i = 0; i < n; i++)
     {
       s = s + elem (i);
-      if (i < size () -1 )
+      if (i < n - 1)
        s += ":";
     }
   return s;
diff --git a/flower/include/file-name.hh b/flower/include/file-name.hh
new file mode 100644 (file)
index 0000000..f05ec44
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+  file-name.hh -- declare File_name
+
+  source file of the Flower Library
+
+  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#ifndef FILE_NAME_HH
+#define FILE_NAME_HH
+
+#include "array.hh"
+#include "string.hh"
+
+class File_name
+{
+public:
+  String root_;
+  String dir_;
+  String base_;
+  String ext_;
+
+  File_name (String);
+    
+  String to_string () const;
+  char const *to_str0 () const;
+};
+
+#endif /* FILE_NAME */
index 40579d00feae289fa0a280b739f9a6016c45b45c..7cd81496f3ea8f1d8b847d8c9259371f67ef95ff 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  file-path.hh -- declare Path and File_path
+  file-path.hh -- declare File_name and File_path
 
   source file of the Flower Library
 
@@ -9,9 +9,8 @@
 #ifndef FILE_PATH_HH
 #define FILE_PATH_HH
 
-#include "string.hh"
 #include "array.hh"
-
+#include "string.hh"
 
 /**    
   search in directories for a file.
    TODO: add a unix style PATH interface 
 */
 
-class Path
-{
-public:
-  String root;
-  String dir;
-  String base;
-  String ext;
-
-  String to_string () const;
-};
-
 class File_path : private Array<String>
 {
 public:
-  String find (String nm) const;
-
-  Array<String>::push;
-  void prepend (String str) { Array<String>::insert (str, 0); }
-  String to_string ()const;
-  bool try_add (String str);
-  void add (String);
+  String find (String name) const;
+  String find (String name, char const *extensions[]);
+  String to_string () const;
+  bool try_append (String str);
+  void append (String str) { Array<String>::push (str); }
   void parse_path (String);
+  void prepend (String str) { Array<String>::insert (str, 0); }
 };
 
-Path split_path (String path);
-
 #endif /* FILE_PATH */
index 84b628052145dfed7d8783f05d0137b04a3c9d1a..e75cdba670100b54ed99c5514bdea4df5fb0f10a 100644 (file)
@@ -28,7 +28,8 @@ typedef Interval_t<int> Slice;        // junkme.
 struct Offset;
 struct Long_option_init;
 struct Rational;
-struct File_path;
+class File_name;
+class File_path;
 struct Getopt_long;
 struct String_data;
 struct String_handle;
index f6d9b5b67d2138992cc52ac3b41832f489667160..b81ebbb885735fa7169b6966678f45d892d2c574 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.2.0"
+\version "2.3.0"
 \header {
   texidoc="@cindex Blank Paper
 
@@ -6,20 +6,19 @@ A blank music paper can be produced also by using invisible notes, and removing
 @code{Bar_number_engraver}.
 
 " }
-\score {
-  \notes {
-    % \clef violin
+
+
+\score \with {
+    \override TimeSignature #'transparent = ##t
+    \override NoteHead #'transparent = ##t
+    defaultBarType = #""
+    \remove Bar_number_engraver
+}
+
+{
+    %% \clef treble
     \clef bass 
     \repeat unfold 3 { c1 \break }
-  }
-  \paper {
-    \context {
-      \ScoreContext
-      \override TimeSignature #'transparent = ##t
-      \override NoteHead #'transparent = ##t
-      defaultBarType = #""
-      \remove Bar_number_engraver
-    }
-  }
 }
 
+
index 824618db5ee14da26304eb51e58e8395657cd8bb..e232f26a274cecd297464e54801bad01d3573637 100644 (file)
 class Paper_outputter
 {
   bool verbatim_scheme_b_;
-
-public:
   SCM output_module_;
   Protected_scm file_;
-  String basename_;
+  String filename_;
+
+  void output_expr (SCM expr, Offset o);
+  void output_metadata (Paper_def*, SCM);
+  void output_music_output_def (Music_output_def* odef);
 
+public:
   Paper_outputter (String nm);
   ~Paper_outputter ();
-  
+
   void dump_scheme (SCM);
-  void output_metadata (Paper_def*, SCM);
-  void output_music_output_def (Music_output_def* odef);
   void output_scheme (SCM scm);
-  void output_expr (SCM expr, Offset o);
+  void output_stencil (Stencil*);
   void output_header (Paper_def*, SCM, int, bool);
   void output_line (SCM, Offset*, bool);
 };
index 0c8ce247e360e05bd0288431e327424e3cd32b63..a3b89c602048cd96cd64b9f079aa1204d459c86c 100644 (file)
 #include <libintl.h>
 #endif
 
-#include "lily-guile.hh"
-#include "lily-version.hh"
 #include "all-font-metrics.hh"
+#include "file-name.hh"
+#include "file-path.hh"
 #include "getopt-long.hh"
+#include "global-ctor.hh"
+#include "kpath.hh"
+#include "lily-guile.hh"
+#include "lily-version.hh"
+#include "main.hh"
+#include "midi-def.hh"
 #include "misc.hh"
+#include "paper-def.hh"
 #include "string.hh"
-#include "main.hh"
-#include "file-path.hh"
 #include "warn.hh"
-#include "lily-guile.hh"
-#include "paper-def.hh"
-#include "midi-def.hh"
-#include "global-ctor.hh"
-#include "kpath.hh"
 
 /*
  * Global options that can be overridden through command line.
@@ -212,7 +212,7 @@ setup_paths ()
   if (char const *lilypond_prefix = getenv ("LILYPONDPREFIX"))
     prefix_directory[1] = lilypond_prefix;
 
-  global_path.add ("");
+  global_path.append ("");
 
   /* Adding mf/out make lilypond unchanged source directory, when setting
      LILYPONDPREFIX to lilypond-x.y.z */
@@ -318,7 +318,7 @@ parse_argv (int argc, char **argv)
 {
   bool help_b = false;
   option_parser = new Getopt_long (argc, argv, options_static);
-  while (Long_option_init const * opt = (*option_parser) ())
+  while (Long_option_init const *opt = (*option_parser) ())
     {
       switch (opt->shortname_char_)
        {
@@ -329,10 +329,10 @@ parse_argv (int argc, char **argv)
        case 'o':
          {
            String s = option_parser->optional_argument_str0_;
-           Path p = split_path (s);
-           if (s != "-" && p.ext.is_empty ())
-             p.ext = output_format_global;
-           output_name_global = p.to_string ();
+           File_name file_name (s);
+           if (s != "-" && file_name.ext_.is_empty ())
+             file_name.ext_ = output_format_global;
+           output_name_global = file_name.to_string ();
          }
          break;
        case 'e':
@@ -356,7 +356,7 @@ parse_argv (int argc, char **argv)
            .push (option_parser->optional_argument_str0_);
          break;
        case 'I':
-         global_path.push (option_parser->optional_argument_str0_);
+         global_path.append (option_parser->optional_argument_str0_);
          break;
        case 'i':
          init_name_global = option_parser->optional_argument_str0_;
index c34351f65de66d253ff4a358c890b1751c8ba044..6922d69d12bbfc6a2e1afee735832ede5b6f246c 100644 (file)
@@ -8,6 +8,7 @@
 */
 
 #include "book.hh"
+#include "file-name.hh"
 #include "file-path.hh"
 #include "lily-version.hh"
 #include "ly-module.hh"
@@ -221,35 +222,6 @@ LY_DEFINE (ly_set_point_and_click, "ly:set-point-and-click", 1, 0, 0,
   return SCM_UNSPECIFIED;
 }
 
-
-/* Distill full input file name from command argument.  PATH describes
-   file name with added default extension, ".ly" if none.  "-" is
-   STDIN.  */
-Path
-distill_inname (String str)
-{
-  Path p = split_path (str);
-  if (str.is_empty () || str == "-")
-    p.base = "-";
-  else
-    {
-      String orig_ext = p.ext;
-      char const *extensions[] = {"ly", "", 0};
-      for (int i = 0; extensions[i]; i++)
-       {
-         p.ext = orig_ext;
-         if (*extensions[i] && !p.ext.is_empty ())
-           p.ext += ".";
-         p.ext += extensions[i];
-         if (!global_path.find (p.to_string ()).is_empty ())
-             break;
-       }
-      /* Reshuffle extension */
-      p = split_path (p.to_string ());
-    }
-  return p;
-}
-
 LY_DEFINE (ly_parse_file, "ly:parse-file",
           1, 0, 0,
           (SCM name),
@@ -258,22 +230,21 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
 {
   SCM_ASSERT_TYPE (ly_c_string_p (name), name, SCM_ARG1, __FUNCTION__, "string");
   char const *file = SCM_STRING_CHARS (name);
-  
-  String infile (file);
-  Path inpath = distill_inname (infile);
+  char const *extensions[] = {"ly", "", 0};
+  String file_name = global_path.find (file, extensions);
   
   /* By default, use base name of input file for output file name */
-  Path outpath = inpath;
-  if (inpath.to_string () != "-")
-    outpath.ext = output_format_global;
+  File_name out_file_name (file_name);
+  if (file_name != "-")
+    out_file_name.ext_ = output_format_global;
   
   /* By default, write output to cwd; do not copy directory part
      of input file name */
-  outpath.root = "";
-  outpath.dir = "";
+  out_file_name.root_ = "";
+  out_file_name.dir_ = "";
   
   if (!output_name_global.is_empty ())
-    outpath = split_path (output_name_global);
+    out_file_name = File_name (output_name_global);
   
   String init;
   if (!init_name_global.is_empty ())
@@ -281,9 +252,7 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
   else
     init = "init.ly";
   
-  String in_file = inpath.to_string ();
-  String out_file = outpath.to_string ();
-
+  String out_file = out_file_name.to_string ();
 
   if (init.length () && global_path.find (init).is_empty ())
     {
@@ -292,30 +261,31 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
       exit (2);
     }
 
-  if ((in_file != "-") && global_path.find (in_file).is_empty ())
+  if ((file_name != "-") && global_path.find (file_name).is_empty ())
     {
-      warning (_f ("can't find file: `%s'", in_file));
-      scm_throw (ly_symbol2scm ("ly-file-failed"), scm_list_1 (scm_makfrom0str (in_file.to_str0 ())));
+      warning (_f ("can't find file: `%s'", file_name));
+      scm_throw (ly_symbol2scm ("ly-file-failed"),
+                scm_list_1 (scm_makfrom0str (file_name.to_str0 ())));
     }
   else
     {
       Sources sources;
       sources.set_path (&global_path);
   
-      progress_indication (_f ("Now processing `%s'", in_file.to_str0 ()));
+      progress_indication (_f ("Now processing `%s'", file_name.to_str0 ()));
       progress_indication ("\n");
 
       My_lily_parser *parser = new My_lily_parser (&sources);
       scm_module_define (global_lily_module, ly_symbol2scm ("parser"),
                         parser->self_scm ());
-      parser->parse_file (init, in_file, out_file);
+      parser->parse_file (init, file_name, out_file);
 
       bool error = parser->error_level_;
       parser = 0;
       if (error)
        /* TODO: pass renamed input file too.  */
        scm_throw (ly_symbol2scm ("ly-file-failed"),
-                  scm_list_1 (scm_makfrom0str (in_file.to_str0 ())));
+                  scm_list_1 (scm_makfrom0str (file_name.to_str0 ())));
     }
   return SCM_UNSPECIFIED;
 }
@@ -386,10 +356,10 @@ LY_DEFINE (ly_parser_print_score, "ly:parser-print-score",
   SCM header = is_module (score->header_) ? score->header_
     : parser->header_.to_SCM ();
   
-  Path outname = split_path (parser->output_basename_);
+  File_name outname (parser->output_basename_);
   int *c = &parser->book_count_;
   if (*c)
-    outname.base += "-" + to_string (*c);
+    outname.base_ += "-" + to_string (*c);
   (*c)++;
 
   SCM os = scm_makfrom0str (outname.to_string ().to_str0 ());
@@ -419,10 +389,10 @@ LY_DEFINE (ly_parser_print_book, "ly:parser-print-book",
   Book *book = unsmob_book (book_smob);
   
   SCM header = parser->header_;
-  Path outname = split_path (parser->output_basename_);
+  File_name outname (parser->output_basename_);
   int *c = &parser->book_count_;
   if (*c)
-    outname.base += "-" + to_string (*c);
+    outname.base_ += "-" + to_string (*c);
   (*c)++;
   Music_output_def *paper = get_paper (parser);
   book->process (outname.to_string (), paper, header);
index d751a0eb87abc6901eaea3555a7e5eaed373a2bd..acf580772b9f03972d3d40ef89ca22169df557e9 100644 (file)
@@ -78,12 +78,7 @@ Paper_def::get_paper_outputter (String outname) const
 {
   progress_indication (_f ("paper output to `%s'...",
                           outname == "-" ? String ("<stdout>") : outname));
-
-  Paper_outputter * po = new Paper_outputter (outname);
-  Path p = split_path (outname);
-  p.ext = "";
-  po->basename_ = p.to_string ();
-  return po;
+  return new Paper_outputter (outname);
 }
 
 Font_metric*
index a648426da89e6f5a192f8e44475e63b7bbbea39a..7a7f7c08830a28f92cb8ff4d1d8d754b2e57b7f7 100644 (file)
@@ -22,6 +22,7 @@
 #include "paper-def.hh"
 #include "paper-line.hh"
 #include "paper-outputter.hh"
+#include "file-name.hh"
 #include "scm-hash.hh"
 #include "stencil.hh"
 #include "string-convert.hh"
 
 Paper_outputter::Paper_outputter (String filename)
 {
-  if (safe_global_b)
-    scm_define (ly_symbol2scm ("safe-mode?"), SCM_BOOL_T);      
-  
+  filename_ = filename;
   file_ = scm_open_file (scm_makfrom0str (filename.to_str0 ()),
                         scm_makfrom0str ("w"));
 
+  if (safe_global_b)
+    scm_define (ly_symbol2scm ("safe-mode?"), SCM_BOOL_T);      
+
   String module_name = "scm output-" + output_format_global;
   if (safe_global_b)
     {
@@ -116,11 +118,15 @@ Paper_outputter::output_metadata (Paper_def *paper, SCM scopes)
     fields
       = scm_cons (ly_symbol2scm (dump_header_fieldnames_global[i].to_str0 ()),
                 fields);
+
+  File_name file_name (filename_);
+  file_name.ext_ = "";
+  String basename = file_name.to_string ();
   output_scheme (scm_list_n (ly_symbol2scm ("output-scopes"),
                             paper->self_scm (),
                             ly_quote_scm (scopes),
                             ly_quote_scm (fields),
-                            scm_makfrom0str (basename_.to_str0 ()), 
+                            scm_makfrom0str (basename.to_str0 ()), 
                             SCM_UNDEFINED));
 }
 
@@ -182,12 +188,17 @@ Paper_outputter::output_line (SCM line, Offset *origin, bool is_last)
   (*origin)[Y_AXIS] += dim[Y_AXIS];
 }
 
+void
+Paper_outputter::output_music_output_def (Music_output_def *odef)
+{
+  output_scheme (scm_list_2 (ly_symbol2scm ("output-paper-def"),
+                             odef->self_scm ()));
+}
 
 void
-Paper_outputter::output_music_output_def (Music_output_def* odef)
+Paper_outputter::output_stencil (Stencil *stil)
 {
-  output_scheme (scm_list_n (ly_symbol2scm ("output-paper-def"),
-                            odef->self_scm (), SCM_UNDEFINED));
+  output_expr (stil->get_expr (), stil->origin ());
 }
 
 /* TODO: replaceme/rewriteme, see output-ps.scm: output-stencil  */
@@ -202,18 +213,17 @@ Paper_outputter::output_expr (SCM expr, Offset o)
       SCM head =ly_car (expr);
       if (unsmob_input (head))
        {
-         Input * ip = unsmob_input (head);
-      
-         output_scheme (scm_list_n (ly_symbol2scm ("define-origin"),
-                                    scm_makfrom0str (ip->file_string ().to_str0 ()),
-                                    scm_int2num (ip->line_number ()),
-                                    scm_int2num (ip->column_number ()),
-                                    SCM_UNDEFINED));
+         Input *ip = unsmob_input (head);
+         output_scheme (scm_list_4 (ly_symbol2scm ("define-origin"),
+                                     scm_makfrom0str (ip->file_string ()
+                                                      .to_str0 ()),
+                                     scm_int2num (ip->line_number ()),
+                                     scm_int2num (ip->column_number ())));
          expr = ly_cadr (expr);
        }
       else  if (head ==  ly_symbol2scm ("no-origin"))
        {
-         output_scheme (scm_list_n (head, SCM_UNDEFINED));
+         output_scheme (scm_list_1 (head));
          expr = ly_cadr (expr);
        }
       else if (head == ly_symbol2scm ("translate-stencil"))
@@ -228,13 +238,11 @@ Paper_outputter::output_expr (SCM expr, Offset o)
        }
       else
        {
-         output_scheme (scm_list_n (ly_symbol2scm ("placebox"),
+         output_scheme (scm_list_4 (ly_symbol2scm ("placebox"),
                                     scm_make_real (o[X_AXIS]),
                                     scm_make_real (o[Y_AXIS]),
-                                    expr,
-                                    SCM_UNDEFINED));
+                                    expr));
          return;
        }
     }
 }
-
index bee85fb5f95a8e7c0d26e5aec9c47302fa7dd0ca..484c59f0c536177486b10c0483e731b466cb718d 100644 (file)
@@ -7,20 +7,21 @@
 */
 
 #include <time.h>
-#include "warn.hh"
-#include "string.hh"
-#include "string-convert.hh"
+
+#include "audio-column.hh"
+#include "audio-item.hh"
+#include "audio-staff.hh"
+#include "file-name.hh"
+#include "lily-version.hh"
 #include "main.hh"
 #include "midi-def.hh"
 #include "midi-item.hh"
 #include "midi-stream.hh"
-#include "audio-column.hh"
-#include "audio-item.hh"
-#include "audio-staff.hh"
 #include "performance.hh"
 #include "score.hh"
-#include "file-path.hh"
-#include "lily-version.hh"
+#include "string-convert.hh"
+#include "string.hh"
+#include "warn.hh"
 
 #include "killing-cons.tcc"
 
@@ -163,9 +164,9 @@ Performance::process (String out)
     out = "lelie.midi";
   
   /* Maybe a bit crude, but we had this before */
-  Path p = split_path (out);
-  p.ext = "midi";
-  out = p.to_string ();
+  File_name file_name (out);
+  file_name.ext_ = "midi";
+  out = file_name.to_string ();
   
   Midi_stream midi_stream (out);
   progress_indication (_f ("MIDI output to `%s'...", out));
index a3d87f7e7aa84d52773eb4387847eaeee53f438d..aab7f1d48c58fc0c266ea0fe3321e2ec9111f75e 100644 (file)
@@ -1,10 +1,10 @@
-/*   
+/*
   scm-option.cc --  implement option setting from Scheme
-  
+
   source file of the GNU LilyPond music typesetter
-  
+
   (c) 2001--2004  Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  
+
  */
 #include <stdio.h>
 
@@ -25,7 +25,7 @@
   preferably, also dont use TESTING_LEVEL_GLOBAL, since it defeats
   another purpose of this very versatile interface, which is to
   support multiple debug/testing options concurrently.
-  
+
  */
 
 
@@ -48,7 +48,7 @@ bool internal_type_checking_global_b;
 
 LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 0, 0, (SCM),
                  "Print ly-set-option usage")
-{  
+{
   printf ( _("lilypond -e EXPR means:").to_str0 ());
   puts ("");
   printf (_ ("  Evalute the Scheme EXPR before parsing any .ly files.").to_str0 ());
@@ -66,7 +66,7 @@ LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 0, 0, (SCM),
           "  midi-debug BOOLEAN\n"
           "  parse-protect BOOLEAN\n"
           "  testing-level INTEGER\n");
-  
+
   exit (0);
   return SCM_UNSPECIFIED;
 }
@@ -104,49 +104,35 @@ LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val),
     val = SCM_BOOL_T;
 
   if (var == ly_symbol2scm ("help"))
-    {
-      /* lilypond -e "(ly-set-option 'help #t)" */
-      ly_option_usage (SCM_EOL);
-    }
+    /* lilypond -e "(ly-set-option 'help #t)" */
+    ly_option_usage (SCM_EOL);
   else if (var == ly_symbol2scm ("midi-debug"))
-    {
-      midi_debug_global_b = to_boolean (val);
-    }
+    midi_debug_global_b = to_boolean (val);
   else if (var == ly_symbol2scm ("testing-level"))
-    {
-     testing_level_global = ly_scm2int (val); 
-    }
+    testing_level_global = ly_scm2int (val);
   else if (var == ly_symbol2scm ("parse-protect" ))
-    {
-      parse_protect_global = to_boolean (val);
-    }
+    parse_protect_global = to_boolean (val);
   else if (var == ly_symbol2scm ("internal-type-checking"))
-    {
-     internal_type_checking_global_b = to_boolean (val); 
-    }
+    internal_type_checking_global_b = to_boolean (val);
   else if (var == ly_symbol2scm ("old-relative"))
     {
       lily_1_8_relative = true;
-      lily_1_8_compatibility_used = false; 
+      /*  Needs to be reset for each file that uses this option.  */
+      lily_1_8_compatibility_used = false;
     }
   else if (var == ly_symbol2scm ("new-relative"))
-    {
-      lily_1_8_relative = false;
-    }
+    lily_1_8_relative = false;
   else if (var == ly_symbol2scm ("debug-beam"))
     {
       extern bool debug_beam_quanting_flag;
       debug_beam_quanting_flag = true;
     }
   else
-    {
-      warning (_("Unknown internal option!"));
-    }
+    warning (_f ("No such internal option: %s", ly_scm2string (var)));
 
   return SCM_UNSPECIFIED;
 }
 
-
 LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var),
            "Get a global option setting.  Supported options include\n"
           "@table @code\n"
@@ -159,22 +145,14 @@ LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var),
           "@end table\n"
           "\n")
 {
+  SCM o = SCM_UNSPECIFIED;
   if (var == ly_symbol2scm ("old-relative-used"))
-    {
-      return ly_bool2scm (lily_1_8_compatibility_used);
-    }
-  if (var == ly_symbol2scm ("old-relative"))
-    {
-      return ly_bool2scm (lily_1_8_relative);
-    }
-  if (var == ly_symbol2scm ("verbose"))
-    {
-      return ly_bool2scm (verbose_global_b);
-    }  
+    o = ly_bool2scm (lily_1_8_compatibility_used);
+  else if (var == ly_symbol2scm ("old-relative"))
+    o = ly_bool2scm (lily_1_8_relative);
+  else if (var == ly_symbol2scm ("verbose"))
+    o = ly_bool2scm (verbose_global_b);
   else
-    {
-      warning (_("Unknown internal option!"));
-    }
-
-  return SCM_UNSPECIFIED;
+    warning (_f ("No such internal option: %s", ly_scm2string (var)));
+  return o;
 }
index 1c800086115c11939c3b990a338b04f3be4823a9..e22e5a5acd686a1f28c9980e5de4a95151f9f775 100644 (file)
 (define-public default-toplevel-music-handler print-music-as-book)
 (define-public default-toplevel-book-handler ly:parser-print-book)
 (define-public default-toplevel-score-handler print-score-as-book)
-;;(define-public toplevel-music-handler print-music-as-book)
-;;(define-public toplevel-music-handler toplevel-music-functions)
-;;(define-public toplevel-music-handler
-;;  (lambda (x y) (print-music-as-book x y)))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;