From: hanwen <hanwen>
Date: Fri, 6 Feb 2004 21:16:10 +0000 (+0000)
Subject: (Snippet.output_print_filename): new
X-Git-Tag: release/2.1.20~16
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b83c739a4d911e0a96f05a38f64755815f88d7f7;p=lilypond.git

(Snippet.output_print_filename): new
file, process printfilename option.
(Snippet.__init__): rewrite: do not use global variables h or
index.
(main): really support -I option.
(find_toplevel_snippets): new code.
(find_toplevel_snippets): reinstate old version, without global variables.
---

diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py
index e7db3fdac9..e2b09713d9 100644
--- a/scripts/lilypond-book.py
+++ b/scripts/lilypond-book.py
@@ -523,10 +523,10 @@ def find_toplevel_snippets (infile, outfile, types):
 	# without searching the string multiple times for one regex.
 	#
 	# Hence, we use earlier results to limit the string portion
-	# where we search. We're hosed if the first type only occurs
-	# at the end of the string, since it  will then use quadratic
-	# time.
-	#
+	# where we search.
+	# Since every part of the string is traversed at most once for
+	# every type of snippet, this is linear.
+	
 	
         while 1:
                 first = None
@@ -551,16 +551,13 @@ def find_toplevel_snippets (infile, outfile, types):
                 snippets.append (found[first])
 
 		outfile.write (s[index:index + found[first].start (0)])
-		outfile.write (found[first].replacement_text ())
+		outfile.write (found[first].replacement_text (format))
 		
                 index += found[first].end (0)
 
         return snippets
 
 
-
-
-
 def filter_pipe (input, cmd):
 	if verbose_p:
 		ly.progress (_ ("Opening filter `%s\'") % cmd)