summaryrefslogtreecommitdiffstats
path: root/modules/nasb/cutil
diff options
context:
space:
mode:
authorTroy A. Griffitts <scribe@crosswire.org>2010-05-24 17:23:24 +0000
committerTroy A. Griffitts <scribe@crosswire.org>2010-05-24 17:23:24 +0000
commit72ceaae8227984f8a81aa502522c9b666514c5b7 (patch)
tree2f6f84f1840793ec8b6b741c4097a1964b924975 /modules/nasb/cutil
parent2efb463de00da866e3ee047e95c9e647f8bae166 (diff)
downloadsword-tools-72ceaae8227984f8a81aa502522c9b666514c5b7.tar.gz
updated for new nasb data-- not completed yet
git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@276 07627401-56e2-0310-80f4-f8cd0041bdcd
Diffstat (limited to 'modules/nasb/cutil')
-rw-r--r--modules/nasb/cutil/nasbosis.cpp45
1 files changed, 26 insertions, 19 deletions
diff --git a/modules/nasb/cutil/nasbosis.cpp b/modules/nasb/cutil/nasbosis.cpp
index cad0126..2532dab 100644
--- a/modules/nasb/cutil/nasbosis.cpp
+++ b/modules/nasb/cutil/nasbosis.cpp
@@ -23,8 +23,10 @@ using namespace sword;
#endif
using std::string;
+using std::cout;
+using std::endl;
-static char *osisOTBooks[] = {
+static const char *osisOTBooks[] = {
"Gen", "Exod", "Lev", "Num", "Deut", "Josh", "Judg",
"Ruth", "1Sam", "2Sam", "1Kgs", "2Kgs", "1Chr",
"2Chr", "Ezra", "Neh", "Esth", "Job", "Ps", "Prov",
@@ -35,29 +37,29 @@ static char *osisOTBooks[] = {
"Bar", "PrAzar", "Bel", "Sus", "1Esd", "2Esd", "AddEsth",
"EpJer", "Jdt", "1Macc", "2Macc", "3Macc", "4Macc", "PrMan",
"Ps151", "Sir", "Tob", "Wis"};
-static char *osisNTBooks[] = {
+static const 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 };
+static const char **osisBooks[] = { osisOTBooks, osisNTBooks };
const char osisMax[2] = {57, 27};
-static char *nasbOTBooks[] = {
+static const char *nasbOTBooks[] = {
"GENESIS", "EXODUS", "LEVITICUS", "NUMBERS", "DEUTERONOMY", "JOSHUA", "JUDGES",
"RUTH", "1 SAMUEL", "2 SAMUEL", "1 KINGS", "2 KINGS", "1 CHRONICLES",
"2 CHRONICLES", "EZRA", "NEHEMIAH", "ESTHER", "JOB", "PSALMS", "PROVERBS",
"ECCLESIASTES", "SONG OF SOLOMON", "ISAIAH", "JEREMIAH", "LAMENTATIONS",
"EZEKIEL", "DANIEL", "HOSEA", "JOEL", "AMOS", "OBADIAH", "JONAH", "MICAH",
"NAHUM", "HABAKKUK", "ZEPHANIAH", "HAGGAI", "ZECHARIAH", "MALACHI"};
-static char *nasbNTBooks[] = {
+static const char *nasbNTBooks[] = {
"MATTHEW", "MARK", "LUKE", "JOHN", "ACTS", "ROMANS", "1 CORINTHIANS",
"2 CORINTHIANS", "GALATIANS", "EPHESIANS", "PHILIPPIANS", "COLOSSIANS",
"1 THESSALONIANS", "2 THESSALONIANS", "1 TIMOTHY", "2 TIMOTHY", "TITUS",
"PHILEMON", "HEBREWS", "JAMES", "1 PETER", "2 PETER", "1 JOHN", "2 JOHN",
"3 JOHN", "JUDE", "REVELATION"};
-static char **nasbBooks[] = { nasbOTBooks, nasbNTBooks };
+static const char **nasbBooks[] = { nasbOTBooks, nasbNTBooks };
const char nasbMax[2] = {39, 27};
char readline(int fd, char **buf) {
@@ -189,6 +191,8 @@ int main(int argc, char **argv) {
// BOOK NAMES <BN>
if (!strncmp(buffer, "<BN>", 4)) {
+ string book = buffer+4;
+ book = book.substr(0, book.find_first_of("<"));
outstring = "";
if (inVerse) {
outstring += "</verse>";
@@ -205,7 +209,7 @@ int main(int argc, char **argv) {
outstring += (string)"<div type=\"book\" osisID=\"";
for (i = 0; i < 2; i++) {
for (j = 0; j < nasbMax[i]; j++) {
- if (!strcmp(buffer+4, nasbBooks[i][j])) {
+ if (book == nasbBooks[i][j]) {
currentBook = osisBooks[i][j];
outstring += currentBook;
currentTestament = i;
@@ -216,17 +220,20 @@ int main(int argc, char **argv) {
break;
}
if (i > 1) {
- fprintf(stderr, "error: %s: couldn't find book match for %s. Please check book array in conversion program.\n", argv[0], buffer+4);
+ fprintf(stderr, "error: %s: couldn't find book match for %s. Please check book array in conversion program.\n", argv[0], book.c_str());
exit(-3);
}
- outstring += (string)"\"><title type=\"main\" subType=\"x-Book\">" + (string)(buffer+4) + "</title>";
+ outstring += (string)"\"><title type=\"main\" subType=\"x-Book\">" + book + "</title>";
inBook = true;
}
// CHAPTERS
- //<SH>PSALM
- if ((!strncmp(buffer, "CHAPTER", 7)) || (!strncmp(buffer, "<SH>PSALM", 9))) {
+ //<SN>PSALM
+ if ((!strncmp(buffer, "<CN>CHAPTER", 11)) || (!strncmp(buffer, "<SN>PSALM", 9))) {
+ string chapterTitle = buffer+4;
+ chapterTitle = chapterTitle.substr(0, chapterTitle.find_first_of("<"));
+ string chapter = chapterTitle.substr((chapterTitle[0] == 'C')?8:6);
outstring = "";
if (inVerse) {
outstring += "</verse>";
@@ -236,18 +243,19 @@ int main(int argc, char **argv) {
outstring += "</chapter>";
inChapter = false;
}
- outstring += (string)"<chapter osisID=\"" + currentBook + (string)"." + (string)(buffer+((*buffer == 'C')?8:10)) + "\">";
- outstring += (string)"<title type=\"sub\" subType=\"x-Chapter\">" + (string)(buffer+((*buffer == 'C')?0:4)) + (string)"</title>";
- currentChapter = atoi(buffer+((*buffer == 'C')?8:10));
+ outstring += (string)"<chapter osisID=\"" + currentBook + "." + chapter + "\">";
+ outstring += (string)"<title type=\"sub\" subType=\"x-Chapter\">" + chapterTitle + "</title>";
+ currentChapter = atoi(chapter.c_str());
inChapter = true;
}
- //<SH>BOOK
//<SH>
- if ((!strncmp(buffer, "<SH>", 4)) && (strncmp(buffer, "<SH>PSALM", 9))) {
+ if (!strncmp(buffer, "<SH>", 4)) {
outstring = "";
- string heading = "";
+ string heading = buffer+4;
+ heading = heading.substr(0, heading.find_first_of("</SH>"));
+
if (!strncmp(lookahead.c_str(), "<PM>", 4)) {
lookahead.erase(0, 4);
outstring += "<milestone type=\"line\" subType=\"x-PM\"/>";
@@ -256,7 +264,6 @@ int main(int argc, char **argv) {
outstring += "</verse>\n";
inVerse = false;
}
- heading += (buffer+4);
const char *found = strstr(buffer+4, "L\\{ORD}/'\\{S}/");
int start = (found) ? (found - (buffer+4)) : -1;
if (start > -1)
@@ -287,7 +294,7 @@ int main(int argc, char **argv) {
// {{x:y}}
-// int start = outstring.find_first_of("{{"); // this is whacked and fails on >[{.. Try it!
+// int start = outstring.find_first_of("{{"); // this is whacked and fails on ">[{.." Try it!
const char *outstr = outstring.c_str();
const char *found = strstr(outstr, "{{");
int start = (found) ? (found - outstr) : -1;