[sword-svn] r276 - trunk/modules/nasb/cutil
scribe at crosswire.org
scribe at crosswire.org
Mon May 24 10:23:24 MST 2010
Author: scribe
Date: 2010-05-24 10:23:24 -0700 (Mon, 24 May 2010)
New Revision: 276
Modified:
trunk/modules/nasb/cutil/nasbosis.cpp
Log:
updated for new nasb data-- not completed yet
Modified: trunk/modules/nasb/cutil/nasbosis.cpp
===================================================================
--- trunk/modules/nasb/cutil/nasbosis.cpp 2010-02-02 18:34:52 UTC (rev 275)
+++ trunk/modules/nasb/cutil/nasbosis.cpp 2010-05-24 17:23:24 UTC (rev 276)
@@ -23,8 +23,10 @@
#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 @@
"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 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
// {{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;
More information about the sword-cvs
mailing list