[sword-cvs] sword/src/keys versekey.cpp,1.63,1.64
sword at www.crosswire.org
sword at www.crosswire.org
Fri May 7 10:22:18 MST 2004
Update of /cvs/core/sword/src/keys
In directory www:/tmp/cvs-serv6848/src/keys
Modified Files:
versekey.cpp
Log Message:
dglassey: add getOSISBookNum to VerseKey so that SWLocale can get a book number from the abbreviation that will be in the new locales
osisbooks etc are moved out of getOSISRef so getOSISBookNum can use them
try to avoid using the same name for local variables and class variables - it's confusing
Index: versekey.cpp
===================================================================
RCS file: /cvs/core/sword/src/keys/versekey.cpp,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- versekey.cpp 20 Apr 2004 12:03:10 -0000 1.63
+++ versekey.cpp 7 May 2004 17:22:16 -0000 1.64
@@ -145,7 +145,7 @@
void VerseKey::setLocale(const char *name) {
char *BMAX;
- struct sbook **books;
+ struct sbook **lbooks;
bool useCache = false;
if (localeCache.name)
@@ -160,8 +160,8 @@
localeCache.locale = locale;
if (locale) {
- locale->getBooks(&BMAX, &books);
- setBooks(BMAX, books);
+ locale->getBooks(&BMAX, &lbooks);
+ setBooks(BMAX, lbooks);
setBookAbbrevs(locale->getBookAbbrevs(), localeCache.abbrevsCnt);
localeCache.abbrevsCnt = abbrevsCnt;
}
@@ -199,7 +199,8 @@
for (int i = 0; i < BMAX[t]; i++) {
int bn = getBookAbbrev(books[t][i].name);
if ((bn-1)%39 != i) {
- SWLog::getSystemLog()->logError("Book: %s does not have a matching toupper abbrevs entry! book number returned was: %d", books[t][i].name, bn);
+ SWLog::getSystemLog()->logError("VerseKey::Book: %s does not have a matching toupper abbrevs entry! book number returned was: %d(%d)",
+ books[t][i].name, bn, i);
}
}
}
@@ -1484,6 +1485,21 @@
return keyval1;
}
+char *VerseKey::osisotbooks[] = {
+ "Gen","Exod","Lev","Num","Deut","Josh","Judg","Ruth","1Sam","2Sam",
+ "1Kgs","2Kgs","1Chr","2Chr","Ezra","Neh","Esth","Job","Ps",
+ "Prov", // added this. Was not in OSIS spec
+ "Eccl",
+ "Song","Isa","Jer","Lam","Ezek","Dan","Hos","Joel","Amos","Obad",
+ "Jonah","Mic","Nah","Hab","Zeph","Hag","Zech","Mal","Bar","PrAzar",
+ "Bel","Sus","1Esd","2Esd","AddEsth","EpJer","Jdt","1Macc","2Macc","3Macc",
+ "4Macc","PrMan","Ps151","Sir","Tob","Wis"};
+char *VerseKey::osisntbooks[] = {
+ "Matt","Mark","Luke","John","Acts","Rom","1Cor","2Cor","Gal","Eph",
+ "Phil","Col","1Thess","2Thess","1Tim","2Tim","Titus","Phlm","Heb","Jas",
+ "1Pet","2Pet","1John","2John","3John","Jude","Rev"};
+char **VerseKey::osisbooks[] = { osisotbooks, osisntbooks };
+
const char *VerseKey::getOSISRef() const {
static char buf[5][254];
@@ -1492,20 +1508,6 @@
if (loop > 4)
loop = 0;
- static char *osisotbooks[] = {
- "Gen","Exod","Lev","Num","Deut","Josh","Judg","Ruth","1Sam","2Sam",
- "1Kgs","2Kgs","1Chr","2Chr","Ezra","Neh","Esth","Job","Ps",
- "Prov", // added this. Was not in OSIS spec
- "Eccl",
- "Song","Isa","Jer","Lam","Ezek","Dan","Hos","Joel","Amos","Obad",
- "Jonah","Mic","Nah","Hab","Zeph","Hag","Zech","Mal","Bar","PrAzar",
- "Bel","Sus","1Esd","2Esd","AddEsth","EpJer","Jdt","1Macc","2Macc","3Macc",
- "4Macc","PrMan","Ps151","Sir","Tob","Wis"};
- static char *osisntbooks[] = {
- "Matt","Mark","Luke","John","Acts","Rom","1Cor","2Cor","Gal","Eph",
- "Phil","Col","1Thess","2Thess","1Tim","2Tim","Titus","Phlm","Heb","Jas",
- "1Pet","2Pet","1John","2John","3John","Jude","Rev"};
- static char **osisbooks[] = { osisotbooks, osisntbooks };
if (Verse())
sprintf(buf[loop], "%s.%d.%d", osisbooks[Testament()-1][Book()-1], (int)Chapter(), (int)Verse());
else if (Chapter())
@@ -1515,6 +1517,28 @@
else sprintf(buf[loop], "");
return buf[loop++];
}
+
+const int VerseKey::getOSISBookNum(const char *bookab) {
+ int i;
+ for (i=0; i < 39; i++)
+ {
+ if (!strncmp(bookab, osisotbooks[i], strlen(osisotbooks[i])))
+ {
+ //printf("VerseKey::getOSISBookNum %s is OT %d\n", bookab, i+1);
+ return i+1;
+ }
+ }
+ for (i=0; i < 27; i++)
+ {
+ if (!strncmp(bookab, osisntbooks[i], strlen(osisotbooks[i])))
+ {
+ //printf("VerseKey::getOSISBookNum %s is NT %d\n", bookab, i+1);
+ return i+1;
+ }
+ }
+ return -1;
+}
+
/******************************************************************************
More information about the sword-cvs
mailing list