Skip to content

Commit aea17ec

Browse files
ydamigosmarzojr
authored andcommitted
compiledb/parser: Unescape input to bashlex parser
Unescape input to bashlex parser. It should address issues nickdiego#124, nickdiego#120 Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
1 parent 170f3f3 commit aea17ec

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiledb/parser.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def skip_line(cmd, reason):
137137

138138
# add entry to database
139139
tokens = c['tokens']
140-
arguments = [unescape(a) for a in tokens[len(wrappers):]]
140+
arguments = [a for a in tokens[len(wrappers):]]
141141

142142
compiler = get_compiler(arguments[0])
143143

@@ -184,7 +184,7 @@ class CommandProcessor(bashlex.ast.nodevisitor):
184184
looking for and extracting compilation commands."""
185185
@staticmethod
186186
def process(line, wd):
187-
trees = bashlex.parser.parse(line)
187+
trees = bashlex.parser.parse(unescape(line))
188188
if not trees:
189189
return []
190190
for tree in trees:
@@ -201,7 +201,7 @@ def process(line, wd):
201201
preprocessed[start:end] = out.strip()
202202
preprocessed = ''.join(preprocessed)
203203

204-
trees = bashlex.parser.parse(preprocessed)
204+
trees = bashlex.parser.parse(unescape(preprocessed))
205205
processor = CommandProcessor(preprocessed, wd)
206206
for tree in trees:
207207
processor.do_process(tree)
@@ -256,6 +256,6 @@ def check_last_cmd(self):
256256

257257

258258
def unescape(s):
259-
return s.encode().decode('unicode_escape')
259+
return s.encode('unicode_escape').decode()
260260

261261
# ex: ts=2 sw=4 et filetype=python

0 commit comments

Comments
 (0)