Browse Source

allow embedded comments

David Rose 21 years ago
parent
commit
6698db48d9
2 changed files with 14 additions and 5 deletions
  1. 10 3
      dtool/src/prc/configPage.cxx
  2. 4 2
      panda/src/doc/howto.use_config.txt

+ 10 - 3
dtool/src/prc/configPage.cxx

@@ -401,9 +401,16 @@ read_prc_line(const string &line) {
   }
   size_t value_begin = p;
 
-  // The value extends from here to the end of the line, so trim
-  // whitespace backwards off from the end of the line.
-  p = line.length();
+  // Is there an embedded comment on this line?
+  p = line.find(" #", value_begin);
+  if (p == string::npos) {
+    // No, the value extends all the way to the end of the line.
+    p = line.length();
+  }
+
+  // The value extends from here to the end of the line (or to the
+  // start of the embedded comment), so trim whitespace backwards off
+  // from there.
   while (p > value_begin && isspace((unsigned char)line[p - 1])) {
     p--;
   }

+ 4 - 2
panda/src/doc/howto.use_config.txt

@@ -44,8 +44,10 @@ This specifies that the variable "load-display" should have the value
 "pandagl".
 
 Comments may also appear in the file; they are introduced by a leading
-hash mark (#).  A comment must be on a line by itself; you may not
-place a comment on the same line with a variable definition.
+hash mark (#).  A comment may be on a line by itself, or it may be on
+the same line following a variable definition; if it is on the same
+line as a variable definition, the hash mark must be preceded by at
+least one space to separate it from the definition.
 
 
 The legal values that you may specify for any particular variable