mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
strip comment from the middle of the line too
This commit is contained in:
parent
5be2e7041b
commit
734ab0dcd1
@ -50,15 +50,28 @@ void ConfigTable::CropString(ConfigString& S) {
|
||||
S.erase(0, ConfigString::npos);
|
||||
}
|
||||
|
||||
void ConfigTable::DeComment(ConfigString& S) {
|
||||
// If the comment delimiter appears in the line followed by
|
||||
// whitespace, strip that part of the line out.
|
||||
|
||||
size_t i = S.find(configcmt);
|
||||
while (i != ConfigString::npos) {
|
||||
if (i + configcmt.length() < S.length() &&
|
||||
isspace(S[i + configcmt.length()])) {
|
||||
// Here's a comment.
|
||||
S.erase(i, ConfigString::npos);
|
||||
return;
|
||||
}
|
||||
|
||||
i = S.find(configcmt, i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
bool ConfigTable::IsComment(const ConfigString& S)
|
||||
{
|
||||
if (!S.empty()) {
|
||||
for (ConfigString::iterator i=configcmt.begin();
|
||||
i!=configcmt.end(); ++i)
|
||||
if (S[0] == (*i))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// Returns true if the line begins with the comment delimiter,
|
||||
// whether or not the delimiter is followed by whitespace.
|
||||
return (S.substr(0, configcmt.length()) == configcmt);
|
||||
}
|
||||
|
||||
void ConfigTable::UpCase(ConfigString& S)
|
||||
@ -89,6 +102,7 @@ void ConfigTable::ParseConfigFile(istream& is, const ConfigString& Filename)
|
||||
if (microconfig_cat->is_spam())
|
||||
microconfig_cat->spam() << "read from " << Filename << ": '" << line
|
||||
<< "'" << endl;
|
||||
DeComment(line);
|
||||
CropString(line);
|
||||
if (microconfig_cat->is_spam())
|
||||
microconfig_cat->spam() << "cropped line to: '" << line << "'"
|
||||
|
@ -56,6 +56,7 @@ class EXPCL_DTOOLCONFIG ConfigTable {
|
||||
ConfigString commandstub;
|
||||
|
||||
static void CropString(ConfigString& S);
|
||||
void DeComment(ConfigString& S);
|
||||
bool IsComment(const ConfigString&);
|
||||
static void UpCase(ConfigString&);
|
||||
ConfigString NextWord(const ConfigString& S);
|
||||
|
Loading…
x
Reference in New Issue
Block a user