Skip to content

Cffi module config_entries don't parse comments. #4976

@stevekanger

Description

@stevekanger

I've been messing with the cffi module and when parsing the config_entries comments are not parsed out. They are strangely placed as values of the following key. So take the following example.

"cffi/custom-module": {
  "module_path": "/path/to/module/module.so",
  "before_comment_key": "before_comment_value",
  // some comment
  "after_comment_key": "after_comment_value"
}

printing like

for (int i = 0; i < config_entries_len; i++) {
    printf(
        "key: %s\nvalue: %s\n\n",
        config_entries[i].key,
        config_entries[i].value
    );
}

will result in

key: after_comment_key
value: 
// some comment
"after_comment_value"


key: before_comment_key
value: "before_comment_value"


key: module_path
value: "/path/to/module/module.so"

As you can see the comment is placed in the following key/value pairs value for some reason. Since waybar supports jsonc comments should be handled gracefully. At this point I think I may be able to parse out the comment but the strange nature of where it's placed leads me to believe this may be fragile and I have no way of knowing if the comment will be placed before, after in the value or in the key or what.

Since waybar supports jsonc as their config language I feel it should be waybar who parses out the comments and gives a little more reliable way for us to parse the config. I could just use a json-c parser but you don't pass the config file used to the module either so there is no way of me knowing the config path. So really at this point im stuck with just not supporting jsonc in a jsonc file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions