Show More
@@ -10,9 +10,9 b'' | |||||
10 | import sys, re, glob |
|
10 | import sys, re, glob | |
11 |
|
11 | |||
12 | def repquote(m): |
|
12 | def repquote(m): | |
13 |
t = re.sub(r"\w", "x", m.group( |
|
13 | t = re.sub(r"\w", "x", m.group('text')) | |
14 | t = re.sub(r"[^\sx]", "o", t) |
|
14 | t = re.sub(r"[^\sx]", "o", t) | |
15 |
return m.group( |
|
15 | return m.group('quote') + t + m.group('quote') | |
16 |
|
16 | |||
17 | def repcomment(m): |
|
17 | def repcomment(m): | |
18 | return m.group(1) + "#" * len(m.group(2)) |
|
18 | return m.group(1) + "#" * len(m.group(2)) | |
@@ -96,10 +96,9 b' pypats = [' | |||||
96 | ] |
|
96 | ] | |
97 |
|
97 | |||
98 | pyfilters = [ |
|
98 | pyfilters = [ | |
99 | (r'''(?<!")(")(([^"\n]|\\")+)"(?!")''', repquote), |
|
99 | (r"""(?msx)(?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!"))) | |
100 | (r"""(?<!')(')(([^'\n]|\\')+)'(?!')""", repquote), |
|
100 | (?P<text>(.*?)) | |
101 | (r"""(''')(([^']|\\'|'{1,2}(?!'))*)'''""", repquote), |
|
101 | (?<!\\)(?P=quote)""", repquote), | |
102 | (r'''(""")(([^"]|\\"|"{1,2}(?!"))*)"""''', repquote), |
|
|||
103 | (r"( *)(#([^\n]*\S)?)", repcomment), |
|
102 | (r"( *)(#([^\n]*\S)?)", repcomment), | |
104 | ] |
|
103 | ] | |
105 |
|
104 | |||
@@ -123,7 +122,7 b' cpats = [' | |||||
123 |
|
122 | |||
124 | cfilters = [ |
|
123 | cfilters = [ | |
125 | (r'(/\*)(((\*(?!/))|[^*])*)\*/', repccomment), |
|
124 | (r'(/\*)(((\*(?!/))|[^*])*)\*/', repccomment), | |
126 |
(r'''(?<!") |
|
125 | (r'''(?P<quote>(?<!")")(?P<text>([^"]|\\")+)"(?!")''', repquote), | |
127 | (r'''(#\s*include\s+<)([^>]+)>''', repinclude), |
|
126 | (r'''(#\s*include\s+<)([^>]+)>''', repinclude), | |
128 | (r'(\()([^)]+\))', repcallspaces), |
|
127 | (r'(\()([^)]+\))', repcallspaces), | |
129 | ] |
|
128 | ] |
@@ -12,5 +12,13 b' def toto( arg1, arg2):' | |||||
12 | return ( 5+6, 9) |
|
12 | return ( 5+6, 9) | |
13 | EOF |
|
13 | EOF | |
14 |
|
14 | |||
|
15 | cat > quote.py <<EOF | |||
|
16 | (''' ( 4x5 ) | |||
|
17 | but """\''' and finally''', | |||
|
18 | """let's fool checkpatch""", '1+2', | |||
|
19 | '"""', 42+1, """and | |||
|
20 | ( 4-1 ) """, "( 1+1 )\" and ") | |||
|
21 | EOF | |||
|
22 | ||||
15 | check_code=`dirname $0`/../contrib/check-code.py |
|
23 | check_code=`dirname $0`/../contrib/check-code.py | |
16 | ${check_code} ./wrong.py ./correct.py |
|
24 | ${check_code} ./wrong.py ./correct.py ./quote.py |
General Comments 0
You need to be logged in to leave comments.
Login now