[sword-cvs] sword/src/mgr filemgr.cpp,1.37,1.38 localemgr.cpp,1.17,1.18 swconfig.cpp,1.14,1.15 swmgr.cpp,1.99,1.100
sword@www.crosswire.org
sword@www.crosswire.org
Fri, 6 Feb 2004 14:01:03 -0700
Update of /cvs/core/sword/src/mgr
In directory www:/tmp/cvs-serv27118/src/mgr
Modified Files:
filemgr.cpp localemgr.cpp swconfig.cpp swmgr.cpp
Log Message:
Changed system[Log|File|Locale]Mgr to
*Mgr *[get|set]System*Mgr() per Daniel Glassey's
discovery of potential problems from order of
initializing statics.
Added new prefix recognition for OSIS lemma prefix
"strong:"
Index: filemgr.cpp
===================================================================
RCS file: /cvs/core/sword/src/mgr/filemgr.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- filemgr.cpp 17 Jan 2004 23:12:46 -0000 1.37
+++ filemgr.cpp 6 Feb 2004 21:01:01 -0000 1.38
@@ -51,7 +51,28 @@
SWORD_NAMESPACE_START
// ---------------- statics -----------------
-FileMgr FileMgr::systemFileMgr;
+FileMgr *FileMgr::systemFileMgr = 0;
+
+class __staticsystemFileMgr {
+public:
+ __staticsystemFileMgr() { }
+ ~__staticsystemFileMgr() { delete FileMgr::systemFileMgr; }
+} _staticsystemFileMgr;
+
+
+FileMgr *FileMgr::getSystemFileMgr() {
+ if (!systemFileMgr)
+ systemFileMgr = new FileMgr();
+
+ return systemFileMgr;
+}
+
+
+void FileMgr::setSystemFileMgr(FileMgr *newFileMgr) {
+ if (systemFileMgr)
+ delete systemFileMgr;
+ systemFileMgr = newFileMgr;
+}
// --------------- end statics --------------
Index: localemgr.cpp
===================================================================
RCS file: /cvs/core/sword/src/mgr/localemgr.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- localemgr.cpp 5 Feb 2004 10:24:36 -0000 1.17
+++ localemgr.cpp 6 Feb 2004 21:01:01 -0000 1.18
@@ -42,11 +42,29 @@
SWORD_NAMESPACE_START
-//LocaleMgr LocaleMgr::systemLocaleMgr;
-LocaleMgr& LocaleMgr::systemLocaleMgr() {
- static LocaleMgr slm;
- return slm;
+LocaleMgr *LocaleMgr::systemLocaleMgr = 0;
+
+class __staticsystemLocaleMgr {
+public:
+ __staticsystemLocaleMgr() { }
+ ~__staticsystemLocaleMgr() { delete LocaleMgr::systemLocaleMgr; }
+} _staticsystemLocaleMgr;
+
+
+LocaleMgr *LocaleMgr::getSystemLocaleMgr() {
+ if (!systemLocaleMgr)
+ systemLocaleMgr = new LocaleMgr();
+
+ return systemLocaleMgr;
}
+
+
+void LocaleMgr::setSystemLocaleMgr(LocaleMgr *newLocaleMgr) {
+ if (systemLocaleMgr)
+ delete systemLocaleMgr;
+ systemLocaleMgr = newLocaleMgr;
+}
+
LocaleMgr::LocaleMgr(const char *iConfigPath) {
locales = new LocaleMap();
Index: swconfig.cpp
===================================================================
RCS file: /cvs/core/sword/src/mgr/swconfig.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- swconfig.cpp 17 Jan 2004 04:33:25 -0000 1.14
+++ swconfig.cpp 6 Feb 2004 21:01:01 -0000 1.15
@@ -87,7 +87,7 @@
Sections.erase(Sections.begin(), Sections.end());
- cfile = FileMgr::systemFileMgr.open(filename.c_str(), O_RDONLY|O_BINARY);
+ cfile = FileMgr::getSystemFileMgr()->open(filename.c_str(), O_RDONLY|O_BINARY);
if (cfile->getFd() > 0) {
while (FileMgr::getLine(cfile, line)) {
buf = new char [ line.length() + 1 ];
@@ -115,7 +115,7 @@
if (!first)
Sections.insert(SectionMap::value_type(sectname, cursect));
- FileMgr::systemFileMgr.close(cfile);
+ FileMgr::getSystemFileMgr()->close(cfile);
}
}
@@ -127,7 +127,7 @@
ConfigEntMap::iterator entry;
SWBuf sectname;
- cfile = FileMgr::systemFileMgr.open(filename.c_str(), O_BINARY|O_RDWR|O_CREAT|O_TRUNC);
+ cfile = FileMgr::getSystemFileMgr()->open(filename.c_str(), O_BINARY|O_RDWR|O_CREAT|O_TRUNC);
if (cfile->getFd() > 0) {
for (sit = Sections.begin(); sit != Sections.end(); sit++) {
@@ -145,7 +145,7 @@
}
buf = "\n";
write(cfile->getFd(), buf.c_str(), buf.length());
- FileMgr::systemFileMgr.close(cfile);
+ FileMgr::getSystemFileMgr()->close(cfile);
}
}
Index: swmgr.cpp
===================================================================
RCS file: /cvs/core/sword/src/mgr/swmgr.cpp,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- swmgr.cpp 31 Jan 2004 00:09:31 -0000 1.99
+++ swmgr.cpp 6 Feb 2004 21:01:01 -0000 1.100
@@ -333,7 +333,7 @@
// check working directory
if (debug)
-// SWLog::systemlog->LogInformation("Checking working directory for mods.conf...");
+// SWLog::getSystemLog()->logInformation("Checking working directory for mods.conf...");
// std::cerr << "Checking working directory for mods.conf...";
if (FileMgr::existsFile(".", "mods.conf")) {
@@ -699,7 +699,7 @@
}
else {
- SWLog::systemlog->LogError("SWMgr: Can't find 'mods.conf' or 'mods.d'. Try setting:\n\tSWORD_PATH=<directory containing mods.conf>\n\tOr see the README file for a full description of setup options (%s)", (configPath) ? configPath : "<configPath is null>");
+ SWLog::getSystemLog()->logError("SWMgr: Can't find 'mods.conf' or 'mods.d'. Try setting:\n\tSWORD_PATH=<directory containing mods.conf>\n\tOr see the README file for a full description of setup options (%s)", (configPath) ? configPath : "<configPath is null>");
ret = -1;
}
@@ -1084,7 +1084,7 @@
int modfd;
char ch;
- SWLog::systemlog->LogTimedInformation("Found new module [%s]. Installing...", fname);
+ SWLog::getSystemLog()->logTimedInformation("Found new module [%s]. Installing...", fname);
modfd = open(fname, O_RDONLY);
ch = '\n';
write(conffd, &ch, 1);