]> git.donarmstrong.com Git - lilypond.git/commitdiff
*** empty log message ***
authorJan Nieuwenhuizen <janneke@gnu.org>
Wed, 4 Feb 2004 23:41:53 +0000 (23:41 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Wed, 4 Feb 2004 23:41:53 +0000 (23:41 +0000)
ChangeLog
scripts/filter-lilypond-book.py

index c22ea8cf7b170fe448ff10a48a20a8c6626c576d..b4876dcbc044522527fead7a848c1bcbaa5083ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-02-05  Jan Nieuwenhuizen  <janneke@gnua.org>
+
+       * scripts/filter-lilypond-book.py (find_toplevel_snippets): Do not
+       discard valid matches.
+
 2004-02-04  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
        * VERSION: release 2.1.18.
index d73ba892b7566ae18132fb71529030b4993eb6aa..cddefa43f0417310fb56e9fb44b3ab0da0d959cc 100644 (file)
@@ -517,31 +517,27 @@ def find_toplevel_snippets (s, types):
        for i in types:
                res[i] = ly.re.compile (snippet_res[format][i])
 
-       length = len (s)
        snippets = []
        index = 0
-       endex = 1000
+       found = {}.fromkeys (types)
        while 1:
-               matches = {}
                first = 0
+               endex = 1 << 30
                for i in types:
-                       matches[i] = res[i].search (s[index:index+endex])
-                       if matches[i]:
-                               start = matches[i].start (0)
-                               if start < endex:
-                                       endex = start
-                               if not first \
-                                      or start < matches[first].start (0):
-                                       first = i
-               if first:
-                       snippets.append (Snippet (first, s, index,
-                                                 matches[first]))
-                       index = index + matches[first].end (0)
-                       endex = 1000
-               elif index + endex < length:
-                       endex *= 2
-               else:
+                       if not found[i] or found[i].start (0) < index:
+                               found[i] = 0
+                               m = res[i].search (s[index:endex])
+                               if m:
+                                       found[i] = Snippet (i, s, index, m)
+                       if found[i] \
+                              and (not first \
+                                   or found[i].start (0) < found[first].start (0)):
+                               first = i
+                               endex = found[first].start (0)
+               if not first:
                        break
+               snippets.append (found[first])
+               index = found[first].end (0)
                
        return snippets
 
@@ -641,23 +637,6 @@ format2ext = {
        LATEX: '.tex',
        }
 
-def find_lilypond_block (a, b):
-       return find_toplevel_snippets (a, b)
-def find_verb (a, b):
-       return find_toplevel_snippets (a, b)
-def find_verbatim (a, b):
-       return find_toplevel_snippets (a, b)
-def find_singleline (a, b):
-       return find_toplevel_snippets (a, b)
-def find_multiline (a, b):
-       return find_toplevel_snippets (a, b)
-def find_lilypond_file (a, b):
-       return find_toplevel_snippets (a, b)
-def find_include (a, b):
-       return find_toplevel_snippets (a, b)
-def find_lilypond (a, b):
-       return find_toplevel_snippets (a, b)
-       
 def do_file (input_filename):
        #ugh
        global format
@@ -682,7 +661,7 @@ def do_file (input_filename):
        #snippets = find_toplevel_snippets (source, snippet_res[format].keys ())
        snippet_types = (
                'lilypond-block',
-               #'verb',
+               'verb',
                'verbatim',
                'singleline-comment',
                'multiline-comment',