compiledb icon indicating copy to clipboard operation
compiledb copied to clipboard

compiledb incorrectly strip quotes.

Open peter50216 opened this issue 5 years ago • 2 comments

Version: using master at commit 88ec08ea36e097dbd8c5ee2ad6123274767d18ea Found this while trying to build kernel with compiledb.

> cat a.log
gcc -DKBUILD_MODNAME='"swap"' ./swap.c

> compiledb --parse a.log
## Processing build commands from a.log
## Writing compilation database with 1 entries to compile_commands.json
## Done.

> cat compile_commands.json
[
 {
  "directory": "/tmp",
  "arguments": [
   "gcc",
   "-DKBUILD_MODNAME=swap",
   "./swap.c"
  ],
  "file": "./swap.c"
 }
]

The single quotes in the argument disappear.

peter50216 avatar Mar 18 '19 07:03 peter50216

I noticed the same thing building Git (compiledb make).

phil-blain avatar Apr 18 '20 23:04 phil-blain

This seems to be an issue with bashlex, e.g.:

In [1]: import bashlex

In [2]: bashlex.parse("""gcc -DVERSION='"1.2.3.4"'""")
Out[2]: [CommandNode(parts=[WordNode(parts=[] pos=(0, 3) word='gcc'), WordNode(parts=[] pos=(4, 25) word='-DVERSION=1.2.3.4')] pos=(0, 25))]

This might be related to https://github.com/idank/bashlex/issues/26 and/or https://github.com/idank/bashlex/pull/56.

drmikehenry avatar Jul 06 '21 00:07 drmikehenry