Use a queue instead of a stack for the list of module paths

A queue is a FIFO while a stack is a LIFO. The code which added paths to the
list of available paths expected them to be checked in the order they were
added, but instead they were checked in reverse order. This meant that one could
no longer replace "system modules" with a .so in ~/.znc/modules.

Thanks to DarthGandalf for noticing and reporting this.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1629 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-09-17 18:39:46 +00:00
parent 3b058ec02a
commit 159649ea96
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -934,7 +934,7 @@ void CModules::GetAvailableMods(set<CModInfo>& ssMods, bool bGlobal) {
ModDirList dirs = GetModDirs();
while (!dirs.empty()) {
Dir.FillByWildcard(dirs.top().first, "*.so");
Dir.FillByWildcard(dirs.front().first, "*.so");
dirs.pop();
for (a = 0; a < Dir.size(); a++) {
@@ -964,8 +964,8 @@ bool CModules::FindModPath(const CString& sModule, CString& sModPath,
ModDirList dirs = GetModDirs();
while (!dirs.empty()) {
sModPath = dirs.top().first + sMod;
sDataPath = dirs.top().second;
sModPath = dirs.front().first + sMod;
sDataPath = dirs.front().second;
dirs.pop();
if (CFile::Exists(sModPath)) {
+2 -2
View File
@@ -15,7 +15,7 @@
#include "Utils.h"
#include <set>
#include <vector>
#include <stack>
#include <queue>
using std::vector;
using std::set;
@@ -471,7 +471,7 @@ public:
CString& sDataPath);
// Return a list of <module dir, data dir> pairs for directories in
// which modules can be found.
typedef std::stack<std::pair<CString, CString> > ModDirList;
typedef std::queue<std::pair<CString, CString> > ModDirList;
static ModDirList GetModDirs();
private: