From bb41e2cd736219772c1fdb55e8cf7dae8e659b06 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 8 Nov 2013 00:08:09 +0100 Subject: [PATCH] Bug with += --- src/parsed_text.py | 1 - src/preprocessed_text.py | 16 ++++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/parsed_text.py b/src/parsed_text.py index 2c07ad1..a63220e 100644 --- a/src/parsed_text.py +++ b/src/parsed_text.py @@ -82,7 +82,6 @@ def check_touch(line,vars,main_vars): all_others = make_single(flatten( map(fun,main_vars) )) all_others.sort() vars.sort() - print vars for x,y in zip(vars,all_others): if x != y: message = "The following entities should be touched:\n" diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index 50a4652..7e7ae4a 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -355,24 +355,15 @@ def add_operators(text): for line in text: buffer = line.text if "+=" in buffer: - if "if" in buffer: + if buffer.lstrip().startswith("if "): re_incr = re.compile(r"(.*)(\))(\s*)(.*)(\+=)(.*$)",re.S) line.text = re.sub(re_incr,r'\1\2\4=\4+(\6)', buffer) else: line.text = re.sub(re_incr,r'\1\2=\2+(\4)', buffer) elif "-=" in buffer: - if "if" in buffer: - re_decr = re.compile(r"(.*)(\))(\s*)(.*)(\-=)(.*$)",re.S) - line.text = re.sub(re_decr,r'\1\2\4=\4-(\6)', buffer) - else: - line.text = re.sub(re_decr,r'\1\2=\2-(\4)', buffer) -# line.text = re.sub(re_decr,r'\1\2=\2-(\4)', buffer) + line.text = re.sub(re_decr,r'\1\2=\2-(\4)', buffer) elif "*=" in buffer: - if "if" in buffer: - re_mult = re.compile(r"(.*)(\))(\s*)(.*)(\*=)(.*$)",re.S) - line.text = re.sub(re_mult,r'\1\2\4=\4*(\6)', buffer) - else: - line.text = re.sub(re_mult,r'\1\2=\2*(\4)', buffer) + line.text = re.sub(re_mult,r'\1\2=\2*(\4)', buffer) result.append(line) return result @@ -671,6 +662,7 @@ def change_includes(text): if type(line) == Include: txt = line.text.replace('"',"'").split("'") if len(txt) != 3: + print txt error.fail(line,"Error in include statement") filename = txt[1].strip() try: