mirror of
https://github.com/g4klx/DMRGateway
synced 2025-12-27 01:06:12 +08:00
permit inline comment
in-line comment enabled example: # conventional comment, the line starts with # [Section] Key=value # this is new style comment Key="quoted value # this is not comment" Key="quoted value" # this is prohibited (not comment) Whether in-line comment is used or not, delete trailing space/tab after value.
This commit is contained in:
11
Conf.cpp
11
Conf.cpp
@@ -240,6 +240,17 @@ bool CConf::read()
|
||||
if (len > 1U && *value == '"' && value[len - 1U] == '"') {
|
||||
value[len - 1U] = '\0';
|
||||
value++;
|
||||
} else {
|
||||
char *p;
|
||||
|
||||
// if value is not quoted, remove after # (to make comment)
|
||||
if ((p = strchr(value, '#')) != NULL)
|
||||
*p = '\0';
|
||||
|
||||
// remove trailing tab/space
|
||||
for (p = value + strlen(value) - 1;
|
||||
p >= value && (*p == '\t' || *p == ' '); p--)
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
if (section == SECTION_GENERAL) {
|
||||
|
||||
Reference in New Issue
Block a user