From 4334f04087d44aac6e4c9d7a27cfa56c86eb93f8 Mon Sep 17 00:00:00 2001 From: hanwen Date: Mon, 22 Apr 2002 16:14:55 +0000 Subject: [PATCH] (re_dict): remove all *? regexps. --- ChangeLog | 6 ++++- scripts/lilypond-book.py | 53 ++++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8ea5954ecb..48dd9bf942 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2002-04-22 Han-Wen Nienhuys + + * scripts/lilypond-book.py (re_dict): remove all *? regexps. + 2002-04-22 Jan Nieuwenhuizen * scripts/lilypond-book.py (re_dict): Fix for python 2.x. @@ -1744,7 +1748,7 @@ * Rewrote new conditional guile >= 1.5 compilation switches, to keep code clean from conditionals and have a concentrated sets of - compatitility fixes for old guile versions. + compatibility fixes for old guile versions. * Fixes for guile 1.4, including embedded ps. diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 413060a70a..9710a8dcc0 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -468,23 +468,23 @@ def output_verbatim (body): re_dict = { - 'latex': {'input': r'(?m)^[^%\n]*?(?P\\mbinput{?([^}\t \n}]*))', - 'include': r'(?m)^[^%\n]*?(?P\\mbinclude{(?P[^}]+)})', + 'latex': {'input': r'(?m)^[^%\n]*(?P\\mbinput{?([^}\t \n}]*))', + 'include': r'(?m)^[^%\n]*(?P\\mbinclude{(?P[^}]+)})', 'option-sep' : ',\s*', - 'header': r"\\documentclass\s*(\[.*?\])?", - 'geometry': r"^(?m)[^%\n]*?\\usepackage\s*(\[(?P.*)\])?\s*{geometry}", + 'header': r"\\documentclass\s*(\[.*\])?", + 'geometry': r"^(?m)[^%\n]*\\usepackage\s*(\[(?P.*)\])?\s*{geometry}", 'preamble-end': r'(?P\\begin{document})', - 'verbatim': r"(?s)(?P\\begin{verbatim}.*?\\end{verbatim})", - 'verb': r"(?P\\verb(?P.).*?(?P=del))", - 'lilypond-file': r'(?m)^[^%\n]*?(?P\\lilypondfile\s*(\[(?P.*?)\])?\s*{(P[^}]+)})', - 'lilypond' : r'(?m)^[^%\n]*?(?P\\lilypond\s*(\[(?P.*?)\])?\s*{(?P.*?)})', - 'lilypond-block': r"(?sm)^[^%\n]*?(?P\\begin\s*(\[(?P.*?)\])?\s*{lilypond}(?P.*?)\\end{lilypond})", + 'verbatim': r"(?s)(?P\\begin{verbatim}.*\\end{verbatim})", + 'verb': r"(?P\\verb(?P.).*(?P=del))", + 'lilypond-file': r'(?m)^[^%\n]*(?P\\lilypondfile\s*(\[(?P.*)\])?\s*{(?P[^}]+)})', + 'lilypond' : r'(?m)^[^%\n]*(?P\\lilypond\s*(\[(?P.*)\])?\s*{(?P.*)})', + 'lilypond-block': r"(?sm)^[^%\n]*(?P\\begin\s*(\[(?P.*)\])?\s*{lilypond}(?P.*)\\end{lilypond})", 'def-post-re': r"\\def\\postLilypondExample", 'def-pre-re': r"\\def\\preLilypondExample", 'usepackage-graphics': r"\usepackage{graphics}", - 'intertext': r',?\s*intertext=\".*?\"', + 'intertext': r',?\s*intertext=\".*\"', 'multiline-comment': no_match, - 'singleline-comment': r"(?m)^.*?(?P(?P^%.*$\n+))", + 'singleline-comment': r"(?m)^.*(?P(?P^%.*$\n+))", 'numcols': r"(?P\\(?Pone|two)column)", }, @@ -493,20 +493,20 @@ re_dict = { 'texi': { - 'include': '(?m)^[^%\n]*?(?P@mbinclude[ \n\t]+(?P[^\t \n]*))', + 'include': '(?m)^[^%\n]*(?P@mbinclude[ \n\t]+(?P[^\t \n]*))', 'input': no_match, 'header': no_match, 'preamble-end': no_match, 'landscape': no_match, - 'verbatim': r"""(?s)(?P@example\s.*?@end example\s)""", - 'verb': r"""(?P@code{.*?})""", - 'lilypond-file': '(?m)^(?P@lilypondfile(\[(?P[^]]*)\])?{(?P[^}]+)})', - 'lilypond' : '(?m)^(?P@lilypond(\[(?P[^]]*)\])?{(?P.*?)})', - 'lilypond-block': r"""(?ms)^(?P@lilypond(\[(?P[^]]*)\])?\s(?P.*?)@end lilypond)\s""", + 'verbatim': r"""(?s)(?P@example\s.*@end example\s)""", + 'verb': r"""(?P@code{.*})""", + 'lilypond-file': r"""(?m)^(?P@lilypondfile(\[(?P[^]]*)\])?{(?P[^}]+)})""", + 'lilypond' : r"""(?m)^(?P@lilypond(\[(?P[^]]*)\])?{(?P.*)})""", + 'lilypond-block': r"""(?ms)^(?P@lilypond(\[(?P[^]]*)\])?\s(?P.*)@end lilypond)\s""", 'option-sep' : ',\s*', - 'intertext': r',?\s*intertext=\".*?\"', - 'multiline-comment': r"(?sm)^\s*(?!@c\s+)(?P@ignore\s.*?@end ignore)\s", - 'singleline-comment': r"(?m)^.*?(?P(?P@c.*$\n+))", + 'intertext': r',?\s*intertext=\".*\"', + 'multiline-comment': r"(?sm)^\s*(?!@c\s+)(?P@ignore\s.*@end ignore)\s", + 'singleline-comment': r"(?m)^.*(?P(?P@c.*$\n+))", 'numcols': no_match, } } @@ -637,8 +637,8 @@ def compose_full_body (body, opts): def parse_options_string(s): d = {} - r1 = re.compile("((\w+)={(.*?)})((,\s*)|$)") - r2 = re.compile("((\w+)=(.*?))((,\s*)|$)") + r1 = re.compile("((\w+)={(.*)})((,\s*)|$)") + r2 = re.compile("((\w+)=(.*))((,\s*)|$)") r3 = re.compile("(\w+?)((,\s*)|$)") while s: m = r1.match(s) @@ -676,7 +676,7 @@ def scan_latex_preamble(chunks): for o in options: if o == 'landscape': paperguru.m_landscape = 1 - m = re.match("(.*?)paper", o) + m = re.match("(.*)paper", o) if m: paperguru.m_papersize = m.group() else: @@ -836,6 +836,7 @@ def chop_chunks(chunks, re_name, func, use_match=0): if c[0] == 'input': str = c[1] while str: + print re_name m = get_re (re_name).search (str) if m == None: newchunks.append (('input', str)) @@ -916,7 +917,7 @@ def schedule_lilypond_block (chunk): file_body = compose_full_body (body, opts) basename = 'lily-' + `abs(hash (file_body))` for o in opts: - m = re.search ('filename="(.*?)"', o) + m = re.search ('filename="(.*)"', o) if m: basename = m.group (1) if not taken_file_names.has_key(basename): @@ -963,7 +964,7 @@ def schedule_lilypond_block (chunk): newbody = output_verbatim (body) for o in opts: - m = re.search ('intertext="(.*?)"', o) + m = re.search ('intertext="(.*)"', o) if m: newbody = newbody + m.group (1) + "\n\n" if format == 'latex': @@ -1260,7 +1261,7 @@ def fix_epswidth (chunks): return '%fpt' % (dims[0] *lmag) - body = re.sub (r"""\\lilypondepswidth{(.*?)}""", replace_eps_dim, c[1]) + body = re.sub (r"""\\lilypondepswidth{(.*)}""", replace_eps_dim, c[1]) newchunks.append(('lilypond', body, c[2], c[3], c[4])) return newchunks -- 2.39.5