diff --git a/doc/overview.xml b/doc/overview.xml
index 52fe9b9865..4ed1e01584 100644
--- a/doc/overview.xml
+++ b/doc/overview.xml
@@ -500,6 +500,9 @@ notify(vm);
The # character introduces a
comment that spans until the end of the line.
+ The ; character at the beginning of
+ a line makes the entire line a comment.
+
The option names are relative to the section names, so
diff --git a/src/config_file.cpp b/src/config_file.cpp
index f2a57b4b82..1373462fbe 100644
--- a/src/config_file.cpp
+++ b/src/config_file.cpp
@@ -90,7 +90,13 @@ namespace boost { namespace program_options { namespace detail {
// strip '#' comments and whitespace
if ((n = s.find('#')) != string::npos)
s = s.substr(0, n);
- s = trim_ws(s);
+ // if the first character is a ';' line is a comment
+ if (!s.empty() && ';' == *s.begin()) {
+ s = "";
+ }
+ else {
+ s = trim_ws(s);
+ }
if (!s.empty()) {
// Handle section name
diff --git a/test/config_test.cfg b/test/config_test.cfg
index 1530f7c8ab..a84e860c22 100644
--- a/test/config_test.cfg
+++ b/test/config_test.cfg
@@ -1,4 +1,6 @@
gv1 = 0#asd
+; semi test
+; semi_value = 9
empty_value =
plug3 = 7
b = true
diff --git a/test/parsers_test.cpp b/test/parsers_test.cpp
index 8f01731dcd..6b883cca46 100644
--- a/test/parsers_test.cpp
+++ b/test/parsers_test.cpp
@@ -257,6 +257,7 @@ void test_config_file(const char* config_file)
desc.add_options()
("gv1", new untyped_value)
("gv2", new untyped_value)
+ ("semi_value", new untyped_value)
("empty_value", new untyped_value)
("plug*", new untyped_value)
("m1.v1", new untyped_value)
@@ -267,6 +268,8 @@ void test_config_file(const char* config_file)
const char content1[] =
" gv1 = 0#asd\n"
+ "; semi comment\n"
+ "; semi_value = 9\n"
"empty_value = \n"
"plug3 = 7\n"
"b = true\n"
@@ -383,6 +386,4 @@ int main(int, char* av[])
test_config_file(av[1]);
test_environment();
test_unregistered();
- return 0;
}
-