allow quotation marks inside config options

This commit is contained in:
Andrzej Rybczak
2009-05-21 22:42:36 +02:00
parent eb3b08b45e
commit 3d9c242f4d
2 changed files with 10 additions and 2 deletions

View File

@@ -45,7 +45,7 @@ Raise/lower volume by given number of percents and exit.
.SH "CONFIGURATION"
When ncmpcpp starts, it tries to read user's settings from the ~/.ncmpcpp/config file. If no user's configuration is found, ncmpcpp uses its default configuration. An example configuration file containing all default values is provided with ncmpcpp and can be found usually in /usr/share/doc/ncmpcpp (exact location may depend on used distribution/OS/configure prefix).
Note: Each config option value must be enclosed in quotation marks (var = "example").
Note: Each config option value must be enclosed in quotation marks (var = "example"). If you want to use quotation mark inside config option, prepend character '\' to it.
Note: COLOR has to be the name (not a number) of one of colors 1-8 from SONG FORMAT section.

View File

@@ -288,12 +288,20 @@ string GetLineValue(string &line, char a, char b, bool once)
size_t i;
for (i = line.find(a); i != string::npos && pos[1] < 0; i = line.find(b, i))
{
if (i && line[i-1] == '\\')
{
i++;
continue;
}
if (once)
line[i] = 0;
pos[pos[0] >= 0] = i++;
}
pos[0]++;
return pos[0] >= 0 && pos[1] >= 0 ? line.substr(pos[0], pos[1]-pos[0]) : "";
string result = pos[0] >= 0 && pos[1] >= 0 ? line.substr(pos[0], pos[1]-pos[0]) : "";
for (i = result.find("\\\""); i != string::npos; i = result.find("\\\""))
result.replace(i, 2, "\"");
return result;
}
void RemoveTheWord(string &s)