mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-23 00:35:53 +08:00
permit inline comment (2)
To implement this feature, using strtok() is not enough. This cannot handle this case: Key=#value#comment it will be #value is the contents of Key. And, Key=value #comment (there is a space and a tab between value and #comment) this will be value<space><tab>. Sometimes these trailing spaces and tabs makes thing wrong. Whether in-line comment is used or not, delete trailing space/tab after value.
This commit is contained in:
10
Conf.cpp
10
Conf.cpp
@@ -391,8 +391,16 @@ bool CConf::read()
|
|||||||
value[len - 1U] = '\0';
|
value[len - 1U] = '\0';
|
||||||
value++;
|
value++;
|
||||||
} else {
|
} else {
|
||||||
|
char *p;
|
||||||
|
|
||||||
// if value is not quoted, remove after # (to make comment)
|
// if value is not quoted, remove after # (to make comment)
|
||||||
strtok(value, "#");
|
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) {
|
if (section == SECTION_GENERAL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user