[sword-svn] r1828 - in trunk: include lib/bcppmake src/mgr
src/modules/comments src/modules/comments/rawcom
src/modules/comments/zcom src/modules/filters
src/modules/texts src/modules/texts/rawtext src/modules/texts/ztext
scribe at crosswire.org
scribe at crosswire.org
Fri Jun 10 09:24:47 MST 2005
Author: scribe
Date: 2005-06-10 09:24:46 -0700 (Fri, 10 Jun 2005)
New Revision: 1828
Modified:
trunk/include/rawcom.h
trunk/include/rawtext.h
trunk/include/swcom.h
trunk/include/swtext.h
trunk/include/zcom.h
trunk/include/ztext.h
trunk/lib/bcppmake/libsword.bpf
trunk/lib/bcppmake/libsword.bpr
trunk/src/mgr/filemgr.cpp
trunk/src/mgr/localemgr.cpp
trunk/src/mgr/swconfig.cpp
trunk/src/modules/comments/rawcom/rawcom.cpp
trunk/src/modules/comments/swcom.cpp
trunk/src/modules/comments/zcom/zcom.cpp
trunk/src/modules/filters/osiswordjs.cpp
trunk/src/modules/texts/rawtext/rawtext.cpp
trunk/src/modules/texts/swtext.cpp
trunk/src/modules/texts/ztext/ztext.cpp
Log:
Pushed some common functionality in VerseKey modules up their base classes
Fixed that common functionality to be per module threadsafe, and use current default locale settings
Fixed filemgr to not strip end of line if we're continuing with a \
Fixed localemgr to set locale name if it doesn't exists. In logic, a locale never 'doesn't exist'; it may not have any translated strings, but it always allows setting of any locale name.
Improved SWConfig to ignore UTF-8 control character at start of file.
Modified: trunk/include/rawcom.h
===================================================================
--- trunk/include/rawcom.h 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/include/rawcom.h 2005-06-10 16:24:46 UTC (rev 1828)
@@ -32,9 +32,7 @@
class SWDLLEXPORT RawCom:public RawVerse, public SWCom {
- VerseKey &getVerseKey();
-
public:
RawCom(const char *ipath, const char *iname = 0, const char *idesc = 0,
Modified: trunk/include/rawtext.h
===================================================================
--- trunk/include/rawtext.h 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/include/rawtext.h 2005-06-10 16:24:46 UTC (rev 1828)
@@ -33,7 +33,6 @@
class SWDLLEXPORT RawText : public SWText, public RawVerse {
- VerseKey &getVerseKey();
RawStr *fastSearch[2];
public:
Modified: trunk/include/swcom.h
===================================================================
--- trunk/include/swcom.h 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/include/swcom.h 2005-06-10 16:24:46 UTC (rev 1828)
@@ -33,6 +33,14 @@
/** The basis for all commentary modules
*/
class SWDLLEXPORT SWCom : public SWModule {
+
+ // for conversion if we have been set with a different internal key type
+ mutable VerseKey tmpVK;
+
+protected:
+ VerseKey &getVerseKey() const;
+
+
public:
/** Initializes data for instance of SWCom
Modified: trunk/include/swtext.h
===================================================================
--- trunk/include/swtext.h 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/include/swtext.h 2005-06-10 16:24:46 UTC (rev 1828)
@@ -34,6 +34,13 @@
/** The basis for all text modules
*/
class SWDLLEXPORT SWText : public SWModule {
+
+ // for conversion if we have been set with a different internal key type
+ mutable VerseKey tmpVK;
+
+protected:
+ VerseKey &getVerseKey() const;
+
public:
/** Initializes data for instance of SWText
*/
Modified: trunk/include/zcom.h
===================================================================
--- trunk/include/zcom.h 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/include/zcom.h 2005-06-10 16:24:46 UTC (rev 1828)
@@ -36,7 +36,6 @@
VerseKey *lastWriteKey;
bool sameBlock(VerseKey * lastWriteKey, VerseKey * key);
int blockType;
- VerseKey &getVerseKey();
public:
Modified: trunk/include/ztext.h
===================================================================
--- trunk/include/ztext.h 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/include/ztext.h 2005-06-10 16:24:46 UTC (rev 1828)
@@ -49,7 +49,6 @@
VerseKey *lastWriteKey;
bool sameBlock(VerseKey * lastWriteKey, VerseKey * key);
int blockType;
- VerseKey &getVerseKey();
public:
Modified: trunk/lib/bcppmake/libsword.bpf
===================================================================
--- trunk/lib/bcppmake/libsword.bpf 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/lib/bcppmake/libsword.bpf 2005-06-10 16:24:46 UTC (rev 1828)
@@ -14,7 +14,6 @@
USEUNIT("..\..\src\mgr\swsearchable.cpp");
USEUNIT("..\..\src\mgr\encfiltmgr.cpp");
USEUNIT("..\..\src\mgr\filemgr.cpp");
-USEUNIT("..\..\src\mgr\ftplibftpt.cpp");
USEUNIT("..\..\src\mgr\ftptrans.cpp");
USEUNIT("..\..\src\mgr\installmgr.cpp");
USEUNIT("..\..\src\mgr\localemgr.cpp");
Modified: trunk/lib/bcppmake/libsword.bpr
===================================================================
--- trunk/lib/bcppmake/libsword.bpr 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/lib/bcppmake/libsword.bpr 2005-06-10 16:24:46 UTC (rev 1828)
@@ -9,17 +9,17 @@
..\..\src\keys\swkey.obj ..\..\src\keys\treekey.obj
..\..\src\keys\treekeyidx.obj ..\..\src\keys\listkey.obj
..\..\src\mgr\swsearchable.obj ..\..\src\mgr\encfiltmgr.obj
- ..\..\src\mgr\filemgr.obj ..\..\src\mgr\ftplibftpt.obj
- ..\..\src\mgr\ftptrans.obj ..\..\src\mgr\installmgr.obj
- ..\..\src\mgr\localemgr.obj ..\..\src\mgr\markupfiltmgr.obj
- ..\..\src\mgr\stringmgr.obj ..\..\src\mgr\swcacher.obj
- ..\..\src\mgr\swconfig.obj ..\..\src\mgr\swfiltermgr.obj
- ..\..\src\mgr\swlocale.obj ..\..\src\mgr\swmgr.obj
- ..\..\src\mgr\curlftpt.obj ..\..\src\utilfuns\utilxml.obj
- ..\..\src\utilfuns\roman.obj ..\..\src\utilfuns\swbuf.obj
- ..\..\src\utilfuns\swobject.obj ..\..\src\utilfuns\swunicod.obj
- ..\..\src\utilfuns\swversion.obj ..\..\src\utilfuns\url.obj
- ..\..\src\utilfuns\utilstr.obj ..\..\src\utilfuns\Greek2Greek.obj
+ ..\..\src\mgr\filemgr.obj ..\..\src\mgr\ftptrans.obj
+ ..\..\src\mgr\installmgr.obj ..\..\src\mgr\localemgr.obj
+ ..\..\src\mgr\markupfiltmgr.obj ..\..\src\mgr\stringmgr.obj
+ ..\..\src\mgr\swcacher.obj ..\..\src\mgr\swconfig.obj
+ ..\..\src\mgr\swfiltermgr.obj ..\..\src\mgr\swlocale.obj
+ ..\..\src\mgr\swmgr.obj ..\..\src\mgr\curlftpt.obj
+ ..\..\src\utilfuns\utilxml.obj ..\..\src\utilfuns\roman.obj
+ ..\..\src\utilfuns\swbuf.obj ..\..\src\utilfuns\swobject.obj
+ ..\..\src\utilfuns\swunicod.obj ..\..\src\utilfuns\swversion.obj
+ ..\..\src\utilfuns\url.obj ..\..\src\utilfuns\utilstr.obj
+ ..\..\src\utilfuns\Greek2Greek.obj
..\..\src\modules\comments\hrefcom\hrefcom.obj
..\..\src\modules\comments\rawcom\rawcom.obj
..\..\src\modules\comments\rawfiles\rawfiles.obj
Modified: trunk/src/mgr/filemgr.cpp
===================================================================
--- trunk/src/mgr/filemgr.cpp 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/src/mgr/filemgr.cpp 2005-06-10 16:24:46 UTC (rev 1828)
@@ -458,9 +458,11 @@
if (!more) {
for (; end > start; end--) {
if ((chunk[end] != 10) && (chunk[end] != 13) && (chunk[end] != ' ') && (chunk[end] != '\t')) {
- if (chunk[end] == '\\')
+ if (chunk[end] == '\\') {
more = true;
- else break;
+ end--;
+ }
+ break;
}
}
}
Modified: trunk/src/mgr/localemgr.cpp
===================================================================
--- trunk/src/mgr/localemgr.cpp 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/src/mgr/localemgr.cpp 2005-06-10 16:24:46 UTC (rev 1828)
@@ -232,12 +232,11 @@
strtok(tmplang, ".");
// also discard after '@' so e.g. @euro locales are found
strtok(tmplang, "@");
- // Before we set it we want to verify that it is an existing locale
+
+ stdstr(&defaultLocaleName, tmplang);
+
// First check for what we ask for
- if (getLocale(tmplang)) {
- stdstr(&defaultLocaleName, tmplang);
- }
- else {
+ if (!getLocale(tmplang)) {
// check for locale without country
char *nocntry=0;
stdstr(&nocntry, tmplang);
@@ -245,14 +244,6 @@
if (getLocale(nocntry)) {
stdstr(&defaultLocaleName, nocntry);
}
- else {
- if (!defaultLocaleName) {
- // make sure we have a default locale name
- // even though the one asked for doesn't exist
- stdstr(&defaultLocaleName, "en_US");
- }
-
- }
delete [] nocntry;
}
delete [] tmplang;
Modified: trunk/src/mgr/swconfig.cpp
===================================================================
--- trunk/src/mgr/swconfig.cpp 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/src/mgr/swconfig.cpp 2005-06-10 16:24:46 UTC (rev 1828)
@@ -37,42 +37,6 @@
SWConfig::~SWConfig() {
}
-
-/*
-char SWConfig::getline(FILE *fp, SWBuf &line)
-{
- char retval = 0;
- char buf[255];
- int len;
-
- line = "";
-
- while (fgets(buf, 254, fp)) {
- while (buf[strlen(buf)-1] == '\n' || buf[strlen(buf)-1] == '\r')
- buf[strlen(buf)-1] = 0;
- len = strlen(buf);
- while (len>0 && buf[len-1] == '\n' || buf[len-1] == '\r')
- buf[(len--)-1] = 0;
-
- if (len>0 && buf[len-1] == '\\') {
- buf[(len--)-1] = 0;
- line += buf;
- continue;
- }
- line += buf;
-
- if (len < 253) {
- retval = 1;
- break;
- }
- }
- return retval;
-}
-*/
-
-
-
-
void SWConfig::Load() {
FileDesc *cfile;
char *buf, *data;
@@ -85,7 +49,17 @@
cfile = FileMgr::getSystemFileMgr()->open(filename.c_str(), FileMgr::RDONLY);
if (cfile->getFd() > 0) {
- while (FileMgr::getLine(cfile, line)) {
+ bool goodLine = FileMgr::getLine(cfile, line);
+
+ // clean UTF encoding tags at start of file
+ while (goodLine && line.length() &&
+ ((((unsigned char)line[0]) == 0xEF) ||
+ (((unsigned char)line[0]) == 0xBB) ||
+ (((unsigned char)line[0]) == 0xBF))) {
+ line << 1;
+ }
+
+ while (goodLine) {
buf = new char [ line.length() + 1 ];
strcpy(buf, line.c_str());
if (*strstrip(buf) == '[') {
@@ -107,6 +81,7 @@
}
}
delete [] buf;
+ goodLine = FileMgr::getLine(cfile, line);
}
if (!first)
Sections.insert(SectionMap::value_type(sectname, cursect));
Modified: trunk/src/modules/comments/rawcom/rawcom.cpp
===================================================================
--- trunk/src/modules/comments/rawcom/rawcom.cpp 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/src/modules/comments/rawcom/rawcom.cpp 2005-06-10 16:24:46 UTC (rev 1828)
@@ -145,33 +145,4 @@
}
-VerseKey &RawCom::getVerseKey() {
- static VerseKey tmpVK;
- VerseKey *key;
- // see if we have a VerseKey * or decendant
- SWTRY {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- SWCATCH ( ... ) { }
- if (!key) {
- ListKey *lkTest = 0;
- SWTRY {
- lkTest = SWDYNAMIC_CAST(ListKey, this->key);
- }
- SWCATCH ( ... ) { }
- if (lkTest) {
- SWTRY {
- key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
- }
- SWCATCH ( ... ) { }
- }
- }
- if (!key) {
- tmpVK = *(this->key);
- return tmpVK;
- }
- else return *key;
-}
-
-
SWORD_NAMESPACE_END
Modified: trunk/src/modules/comments/swcom.cpp
===================================================================
--- trunk/src/modules/comments/swcom.cpp 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/src/modules/comments/swcom.cpp 2005-06-10 16:24:46 UTC (rev 1828)
@@ -4,6 +4,7 @@
*/
#include <swcom.h>
+#include <localemgr.h>
SWORD_NAMESPACE_START
@@ -15,8 +16,7 @@
* idisp - Display object to use for displaying
*/
-SWCom::SWCom(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang): SWModule(imodname, imoddesc, idisp, "Commentaries", enc, dir, mark, ilang)
-{
+SWCom::SWCom(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang): SWModule(imodname, imoddesc, idisp, "Commentaries", enc, dir, mark, ilang), tmpVK() {
delete key;
key = CreateKey();
}
@@ -26,8 +26,7 @@
* SWCom Destructor - Cleans up instance of SWCom
*/
-SWCom::~SWCom()
-{
+SWCom::~SWCom() {
}
@@ -68,4 +67,33 @@
return Index();
}
+
+VerseKey &SWCom::getVerseKey() const {
+ VerseKey *key;
+ // see if we have a VerseKey * or decendant
+ SWTRY {
+ key = SWDYNAMIC_CAST(VerseKey, this->key);
+ }
+ SWCATCH ( ... ) { }
+ if (!key) {
+ ListKey *lkTest = 0;
+ SWTRY {
+ lkTest = SWDYNAMIC_CAST(ListKey, this->key);
+ }
+ SWCATCH ( ... ) { }
+ if (lkTest) {
+ SWTRY {
+ key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
+ }
+ SWCATCH ( ... ) { }
+ }
+ }
+ if (!key) {
+ tmpVK.setLocale(LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName());
+ tmpVK = *(this->key);
+ return tmpVK;
+ }
+ else return *key;
+}
+
SWORD_NAMESPACE_END
Modified: trunk/src/modules/comments/zcom/zcom.cpp
===================================================================
--- trunk/src/modules/comments/zcom/zcom.cpp 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/src/modules/comments/zcom/zcom.cpp 2005-06-10 16:24:46 UTC (rev 1828)
@@ -177,33 +177,4 @@
}
-VerseKey &zCom::getVerseKey() {
- static VerseKey tmpVK;
- VerseKey *key;
- // see if we have a VerseKey * or decendant
- SWTRY {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- SWCATCH ( ... ) { }
- if (!key) {
- ListKey *lkTest = 0;
- SWTRY {
- lkTest = SWDYNAMIC_CAST(ListKey, this->key);
- }
- SWCATCH ( ... ) { }
- if (lkTest) {
- SWTRY {
- key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
- }
- SWCATCH ( ... ) { }
- }
- }
- if (!key) {
- tmpVK = *(this->key);
- return tmpVK;
- }
- else return *key;
-}
-
-
SWORD_NAMESPACE_END
Modified: trunk/src/modules/filters/osiswordjs.cpp
===================================================================
--- trunk/src/modules/filters/osiswordjs.cpp 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/src/modules/filters/osiswordjs.cpp 2005-06-10 16:24:46 UTC (rev 1828)
@@ -49,7 +49,7 @@
char *ch;
SWBuf modName = (module)?module->Name():"";
// add TR to w src in KJV then remove this next line
- SWBuf wordSrcPrefix = (modName == "KJV")?"TR":modName;
+ SWBuf wordSrcPrefix = (modName == "KJV")?SWBuf("TR"):modName;
const SWBuf orig = text;
const char * from = orig.c_str();
Modified: trunk/src/modules/texts/rawtext/rawtext.cpp
===================================================================
--- trunk/src/modules/texts/rawtext/rawtext.cpp 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/src/modules/texts/rawtext/rawtext.cpp 2005-06-10 16:24:46 UTC (rev 1828)
@@ -78,35 +78,6 @@
}
-VerseKey &RawText::getVerseKey() {
- static VerseKey tmpVK;
- VerseKey *key;
- // see if we have a VerseKey * or decendant
- SWTRY {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- SWCATCH ( ... ) { }
- if (!key) {
- ListKey *lkTest = 0;
- SWTRY {
- lkTest = SWDYNAMIC_CAST(ListKey, this->key);
- }
- SWCATCH ( ... ) { }
- if (lkTest) {
- SWTRY {
- key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
- }
- SWCATCH ( ... ) { }
- }
- }
- if (!key) {
- tmpVK = *(this->key);
- return tmpVK;
- }
- else return *key;
-}
-
-
/******************************************************************************
* RawText::getRawEntry - Returns the correct verse when char * cast
* is requested
Modified: trunk/src/modules/texts/swtext.cpp
===================================================================
--- trunk/src/modules/texts/swtext.cpp 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/src/modules/texts/swtext.cpp 2005-06-10 16:24:46 UTC (rev 1828)
@@ -4,6 +4,7 @@
#include <swtext.h>
#include <listkey.h>
+#include <localemgr.h>
SWORD_NAMESPACE_START
@@ -15,8 +16,7 @@
* idisp - Display object to use for displaying
*/
-SWText::SWText(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang): SWModule(imodname, imoddesc, idisp, "Biblical Texts", enc, dir, mark, ilang)
-{
+SWText::SWText(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang): SWModule(imodname, imoddesc, idisp, "Biblical Texts", enc, dir, mark, ilang), tmpVK() {
delete key;
key = CreateKey();
skipConsecutiveLinks = false;
@@ -35,8 +35,7 @@
* SWText CreateKey - Create the correct key (VerseKey) for use with SWText
*/
-SWKey *SWText::CreateKey()
-{
+SWKey *SWText::CreateKey() {
return new VerseKey();
}
@@ -78,4 +77,34 @@
return Index();
}
+
+VerseKey &SWText::getVerseKey() const {
+ VerseKey *key;
+ // see if we have a VerseKey * or decendant
+ SWTRY {
+ key = SWDYNAMIC_CAST(VerseKey, this->key);
+ }
+ SWCATCH ( ... ) { }
+ if (!key) {
+ ListKey *lkTest = 0;
+ SWTRY {
+ lkTest = SWDYNAMIC_CAST(ListKey, this->key);
+ }
+ SWCATCH ( ... ) { }
+ if (lkTest) {
+ SWTRY {
+ key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
+ }
+ SWCATCH ( ... ) { }
+ }
+ }
+ if (!key) {
+ tmpVK.setLocale(LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName());
+ tmpVK = *(this->key);
+ return tmpVK;
+ }
+ else return *key;
+}
+
+
SWORD_NAMESPACE_END
Modified: trunk/src/modules/texts/ztext/ztext.cpp
===================================================================
--- trunk/src/modules/texts/ztext/ztext.cpp 2005-06-10 13:21:34 UTC (rev 1827)
+++ trunk/src/modules/texts/ztext/ztext.cpp 2005-06-10 16:24:46 UTC (rev 1828)
@@ -186,32 +186,5 @@
}
-VerseKey &zText::getVerseKey() {
- static VerseKey tmpVK;
- VerseKey *key;
- // see if we have a VerseKey * or decendant
- SWTRY {
- key = SWDYNAMIC_CAST(VerseKey, this->key);
- }
- SWCATCH ( ... ) { }
- if (!key) {
- ListKey *lkTest = 0;
- SWTRY {
- lkTest = SWDYNAMIC_CAST(ListKey, this->key);
- }
- SWCATCH ( ... ) { }
- if (lkTest) {
- SWTRY {
- key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
- }
- SWCATCH ( ... ) { }
- }
- }
- if (!key) {
- tmpVK = *(this->key);
- return tmpVK;
- }
- else return *key;
-}
SWORD_NAMESPACE_END
More information about the sword-cvs
mailing list