mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -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);
|
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)
|
bool ConfigTable::IsComment(const ConfigString& S)
|
||||||
{
|
{
|
||||||
if (!S.empty()) {
|
// Returns true if the line begins with the comment delimiter,
|
||||||
for (ConfigString::iterator i=configcmt.begin();
|
// whether or not the delimiter is followed by whitespace.
|
||||||
i!=configcmt.end(); ++i)
|
return (S.substr(0, configcmt.length()) == configcmt);
|
||||||
if (S[0] == (*i))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigTable::UpCase(ConfigString& S)
|
void ConfigTable::UpCase(ConfigString& S)
|
||||||
@ -89,6 +102,7 @@ void ConfigTable::ParseConfigFile(istream& is, const ConfigString& Filename)
|
|||||||
if (microconfig_cat->is_spam())
|
if (microconfig_cat->is_spam())
|
||||||
microconfig_cat->spam() << "read from " << Filename << ": '" << line
|
microconfig_cat->spam() << "read from " << Filename << ": '" << line
|
||||||
<< "'" << endl;
|
<< "'" << endl;
|
||||||
|
DeComment(line);
|
||||||
CropString(line);
|
CropString(line);
|
||||||
if (microconfig_cat->is_spam())
|
if (microconfig_cat->is_spam())
|
||||||
microconfig_cat->spam() << "cropped line to: '" << line << "'"
|
microconfig_cat->spam() << "cropped line to: '" << line << "'"
|
||||||
|
@ -56,6 +56,7 @@ class EXPCL_DTOOLCONFIG ConfigTable {
|
|||||||
ConfigString commandstub;
|
ConfigString commandstub;
|
||||||
|
|
||||||
static void CropString(ConfigString& S);
|
static void CropString(ConfigString& S);
|
||||||
|
void DeComment(ConfigString& S);
|
||||||
bool IsComment(const ConfigString&);
|
bool IsComment(const ConfigString&);
|
||||||
static void UpCase(ConfigString&);
|
static void UpCase(ConfigString&);
|
||||||
ConfigString NextWord(const ConfigString& S);
|
ConfigString NextWord(const ConfigString& S);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user