From e9364954f1a27546f8ab6b829013d6f319dd73a4 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Fri, 6 Feb 2004 21:16:10 +0000 Subject: [PATCH] (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. --- scripts/lilypond-book.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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) -- 2.39.5