Revert r1738-1742

This broke webadmin, changed CString::Token()'s behavior possibly breaking a lot
of stuff just before a release and added an unused config entry.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1748 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2010-02-08 13:49:44 +00:00
parent 7bb6c2ad7a
commit 702faeeed5
8 changed files with 28 additions and 103 deletions
+22 -36
View File
@@ -90,30 +90,26 @@ void CTemplate::Init() {
}
*/
ClearPaths();
ClearPath();
m_pParent = NULL;
}
CString CTemplate::ExpandFile(const CString& sFilename, bool bFromInc) {
/*if (sFilename.Left(1) == "/" || sFilename.Left(2) == "./") {
CString CTemplate::ExpandFile(const CString& sFilename) {
if (sFilename.Left(1) == "/" || sFilename.Left(2) == "./") {
return sFilename;
}*/
}
CString sFile(ResolveLiteral(sFilename).TrimLeft_n("/"));
CString sFile(ResolveLiteral(sFilename));
for (list<pair<CString, bool> >::iterator it = m_lsbPaths.begin(); it != m_lsbPaths.end(); it++) {
if (it->second && !bFromInc) {
continue;
}
CString sRoot = it->first;
for (LCString::iterator it = m_lsPaths.begin(); it != m_lsPaths.end(); it++) {
CString sRoot = *it;
CString sFilePath(CDir::ChangeDir(sRoot, sFile));
if (CFile::Exists(sFilePath)) {
// This only works if sRoot got a trailing slash! The
// code which adds paths makes sure this is true.
if (sRoot.empty() || sFilePath.Left(sRoot.length()) == sRoot) {
DEBUG("\t\tFound [" + sFilePath + "]\n");
//DEBUG("\t\tFound [" + sFilePath + "]\n");
return sFilePath;
} else {
DEBUG("\t\tOutside of root [" + sFilePath + "] !~ [" + sRoot + "]");
@@ -123,15 +119,15 @@ CString CTemplate::ExpandFile(const CString& sFilename, bool bFromInc) {
}
}
switch (m_lsbPaths.size()) {
switch (m_lsPaths.size()) {
case 0:
DEBUG("Unable to find [" + sFile + "] using the current directory");
break;
case 1:
DEBUG("Unable to find [" + sFile + "] in the defined path [" + m_lsbPaths.begin()->first + "]");
DEBUG("Unable to find [" + sFile + "] in the defined path [" + *m_lsPaths.begin());
break;
default:
DEBUG("Unable to find [" + sFile + "] in any of the " + CString(m_lsbPaths.size()) + " defined paths");
DEBUG("Unable to find [" + sFile + "] in any of the " + CString(m_lsPaths.size()) + " defined paths");
}
return "";
@@ -142,39 +138,31 @@ void CTemplate::SetPath(const CString& sPaths) {
sPaths.Split(":", vsDirs, false);
for (size_t a = 0; a < vsDirs.size(); a++) {
AppendPath(vsDirs[a], false);
AppendPath(vsDirs[a]);
}
}
void CTemplate::PrependPath(const CString& sPath, bool bIncludesOnly) {
void CTemplate::PrependPath(const CString& sPath) {
DEBUG("CTemplate::PrependPath(" + sPath + ") == [" + CDir::ChangeDir("./", sPath + "/") + "]");
m_lsbPaths.push_front(make_pair(CDir::ChangeDir("./", sPath + "/"), bIncludesOnly));
m_lsPaths.push_front(CDir::ChangeDir("./", sPath + "/"));
}
void CTemplate::AppendPath(const CString& sPath, bool bIncludesOnly) {
void CTemplate::AppendPath(const CString& sPath) {
DEBUG("CTemplate::AppendPath(" + sPath + ") == [" + CDir::ChangeDir("./", sPath + "/") + "]");
m_lsbPaths.push_back(make_pair(CDir::ChangeDir("./", sPath + "/"), bIncludesOnly));
m_lsPaths.push_back(CDir::ChangeDir("./", sPath + "/"));
}
void CTemplate::RemovePath(const CString& sPath) {
DEBUG("CTemplate::RemovePath(" + sPath + ") == [" + CDir::ChangeDir("./", sPath + "/") + "]");
//m_lsbPaths.remove(CDir::ChangeDir("./", sPath + "/"));
for (list<pair<CString, bool> >::iterator it = m_lsbPaths.begin(); it != m_lsbPaths.end(); it++) {
if (it->first == sPath) {
m_lsbPaths.remove(*it);
RemovePath(sPath);
return;
}
}
m_lsPaths.remove(CDir::ChangeDir("./", sPath + "/"));
}
void CTemplate::ClearPaths() {
m_lsbPaths.clear();
void CTemplate::ClearPath() {
m_lsPaths.clear();
}
bool CTemplate::SetFile(const CString& sFileName) {
m_sFileName = ExpandFile(sFileName, false);
m_sFileName = ExpandFile(sFileName);
PrependPath(sFileName + "/..");
if (sFileName.empty()) {
@@ -242,7 +230,6 @@ bool CTemplate::PrintString(CString& sRet) {
}
bool CTemplate::Print(ostream& oOut) {
DEBUG("== Print(o) m_sFileName = [" + m_sFileName + "]");
return Print(m_sFileName, oOut);
}
@@ -324,8 +311,7 @@ bool CTemplate::Print(const CString& sFileName, ostream& oOut) {
if (!uSkip) {
if (sAction.Equals("INC")) {
if (!Print(ExpandFile(sArgs, true), oOut)) {
DEBUG("Unable to print INC'd file [" + sArgs + "]");
if (!Print(ExpandFile(sArgs), oOut)) {
return false;
}
} else if (sAction.Equals("SETOPTION")) {
@@ -379,7 +365,7 @@ bool CTemplate::Print(const CString& sFileName, ostream& oOut) {
sSetBlockVar = sArgs;
bInSetBlock = true;
} else if (sAction.Equals("EXPAND")) {
sOutput += ExpandFile(sArgs, true);
sOutput += ExpandFile(sArgs);
} else if (sAction.Equals("VAR")) {
sOutput += GetValue(sArgs);
} else if (sAction.Equals("LT")) {