cbfmt icon indicating copy to clipboard operation
cbfmt copied to clipboard

Does not handle spaces in arguments well

Open UtkarshVerma opened this issue 2 years ago • 2 comments
trafficstars

I'm trying to have cbfmt autoformat my C code blocks using clang-format with the following config:

[languages]
c = ["clang-format -style=\"{BasedOnStyle: Google, IndentWidth: 4, UseTab: Never, TabWidth: 4}\""]

However, it seems to split args on spaces without respecting the escaped quote. clang-format thinks that it has received 6 filenames which yields the error:

$ cbfmt -w test.md
[Error]: test.md:3 [c] -> [clang-format]
No such file or directory
No such file or directory
No such file or directory
No such file or directory
No such file or directory
No such file or directory
No such file or directory


[0/1] files were written.

Here's my test markdown file:

Hello

```c
struct MailStructure {
  unsigned int data : 18;  // Assuming data is 18 bits
  unsigned int reserved : 10;
  unsigned int channel : 4;
};
```

UtkarshVerma avatar Aug 18 '23 03:08 UtkarshVerma

Yeah it naively just splits by whitespace at the moment.

I'll look into this when I have some time.

For now, I guess an easy workaround is to just not use spaces.

lukas-reineke avatar Aug 18 '23 08:08 lukas-reineke

Thanks, please take your time. I'm using .clang-format for the time being, as the style argument strictly requires spaces.

UtkarshVerma avatar Aug 22 '23 04:08 UtkarshVerma