]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/includable-lexer.cc
* lily/figured-bass-engraver.cc (process_music): change calling
[lilypond.git] / lily / includable-lexer.cc
index 440b9d507acbdc2aa3c17aeedb253ba3675f6378..aab8fd9fcd850446fae03fb0f7f4469a12608e30 100644 (file)
@@ -3,14 +3,14 @@
 
   source file of the LilyPond music typesetter
 
-  (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include <sstream>
+#include "config.h"
 
-
-#include "file-path.hh"
 #include "includable-lexer.hh"
+#include "file-path.hh"
 #include "source-file.hh"
 #include "source.hh"
 #include "warn.hh"
 #define YYSTATE YY_START
 #endif
 
+/* Flex >= 2.5.29 has include stack; but we don't use that yet.  */
+#ifndef HAVE_FLEXLEXER_YY_CURRENT_BUFFER
+#define yy_current_buffer \
+  (yy_buffer_stack != 0 ? yy_buffer_stack[yy_buffer_stack_top] : 0)
+#endif
+
 Includable_lexer::Includable_lexer ()
 {
+#ifdef HAVE_FLEXLEXER_YY_CURRENT_BUFFER
   yy_current_buffer = 0;
+#endif
   allow_includes_b_ = true;
 }
 
@@ -39,7 +47,7 @@ Includable_lexer::new_input (String s, Sources  * global_sources)
 {
   if (!allow_includes_b_)
     {
-      LexerError ("include files are disallowed.");
+      LexerError (_ ("include files are not allowed").to_str0 ());
       return;
     }
   
@@ -48,7 +56,7 @@ Includable_lexer::new_input (String s, Sources  * global_sources)
     {
       String msg = _f ("can't find file: `%s'", s);
       msg += "\n";
-      msg += _f ("(search path: `%s')", global_sources->path_C_->string ().to_str0 ());
+      msg += _f ("(search path: `%s')", global_sources->path_C_->to_string ().to_str0 ());
       msg += "\n";
       LexerError (msg.to_str0 ());
 
@@ -106,10 +114,14 @@ Includable_lexer::close_input ()
   if (verbose_global_b)
     progress_indication ("]");
   yy_delete_buffer (yy_current_buffer);
+#ifdef HAVE_FLEXLEXER_YY_CURRENT_BUFFER  
   yy_current_buffer = 0;
-  if (state_stack_.empty ())
+#endif  
+  if (state_stack_.is_empty ())
     {
+#ifdef HAVE_FLEXLEXER_YY_CURRENT_BUFFER  
       yy_current_buffer = 0;
+#endif  
       return false;
     }
   else
@@ -122,14 +134,14 @@ Includable_lexer::close_input ()
 char const*
 Includable_lexer::here_str0 () const
 {
-  if (include_stack_.empty ())
+  if (include_stack_.is_empty ())
     return 0;
   return include_stack_.top ()->to_str0 () + char_count_stack_.top ();
 }
 
 Includable_lexer::~Includable_lexer ()
 {
-  while (!include_stack_.empty ())
+  while (!include_stack_.is_empty ())
     {
       close_input ();
     }
@@ -147,7 +159,7 @@ Includable_lexer::add_lexed_char (int count)
 Source_file*
 Includable_lexer::get_source_file () const
 {
-  if (include_stack_.empty ())
+  if (include_stack_.is_empty ())
     return 0;
   else
     return include_stack_.top ();