Skip to content

Commit 0c957ed

Browse files
committed
tools: better escapes for re.sub
1 parent f688284 commit 0c957ed

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tools/generate_func.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
if tmp or \
4949
line.startswith('TA_RetCode TA_') or \
5050
line.startswith('int TA_'):
51-
line = re.sub('/\*[^\*]+\*/', '', line) # strip comments
51+
line = re.sub(r'/\*[^\*]+\*/', '', line) # strip comments
5252
tmp.append(line)
5353
if not line:
5454
s = ' '.join(tmp)
55-
s = re.sub('\s+', ' ', s)
55+
s = re.sub(r'\s+', ' ', s)
5656
functions.append(s)
5757
tmp = []
5858

@@ -225,7 +225,7 @@ def cleanup(name):
225225
i = f.index('(')
226226
name = f[:i].split()[1]
227227
args = f[i:].split(',')
228-
args = [re.sub('[\(\);]', '', s).strip() for s in args]
228+
args = [re.sub(r'[\(\);]', '', s).strip() for s in args]
229229

230230
shortname = name[3:]
231231
names.append(shortname)

tools/generate_stream.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
if tmp or \
4949
line.startswith('TA_RetCode TA_') or \
5050
line.startswith('int TA_'):
51-
line = re.sub('/\*[^\*]+\*/', '', line) # strip comments
51+
line = re.sub(r'/\*[^\*]+\*/', '', line) # strip comments
5252
tmp.append(line)
5353
if not line:
5454
s = ' '.join(tmp)
55-
s = re.sub('\s+', ' ', s)
55+
s = re.sub(r'\s+', ' ', s)
5656
functions.append(s)
5757
tmp = []
5858

@@ -92,7 +92,7 @@ def cleanup(name):
9292
i = f.index('(')
9393
name = f[:i].split()[1]
9494
args = f[i:].split(',')
95-
args = [re.sub('[\(\);]', '', s).strip() for s in args]
95+
args = [re.sub(r'[\(\);]', '', s).strip() for s in args]
9696

9797
shortname = name[3:]
9898
names.append(shortname)

0 commit comments

Comments
 (0)