From c9458897ebbb739d8db83c80e06512d8a612f743 Mon Sep 17 00:00:00 2001
From: danglassey
Date: Wed, 14 Aug 2002 09:57:17 +0000
Subject: *** empty log message ***
---
src/modules/texts/Makefile | 5 +
src/modules/texts/Makefile.am | 7 +
src/modules/texts/rawgbf/Gbf.c | 485 +++++++++++++
src/modules/texts/rawgbf/Gbf.pas | 735 +++++++++++++++++++
src/modules/texts/rawgbf/Gbfmain.pas | 1267 +++++++++++++++++++++++++++++++++
src/modules/texts/rawgbf/Makefile | 5 +
src/modules/texts/rawgbf/Makefile.am | 4 +
src/modules/texts/rawgbf/gbf.cpp | 735 +++++++++++++++++++
src/modules/texts/rawgbf/gbf.h | 67 ++
src/modules/texts/rawgbf/gbfidx.cpp | 294 ++++++++
src/modules/texts/rawgbf/rawgbf.cpp | 84 +++
src/modules/texts/rawtext/Makefile | 5 +
src/modules/texts/rawtext/Makefile.am | 4 +
src/modules/texts/rawtext/kjvidx.cpp | 169 +++++
src/modules/texts/rawtext/makebnds.c | 86 +++
src/modules/texts/rawtext/nuidx.cpp | 238 +++++++
src/modules/texts/rawtext/ojbtxidx.c | 166 +++++
src/modules/texts/rawtext/rawtext.cpp | 580 +++++++++++++++
src/modules/texts/rawtext/rawtxidx.c | 146 ++++
src/modules/texts/rawtext/rtfidx.cpp | 164 +++++
src/modules/texts/rawtext/svetxidx.c | 153 ++++
src/modules/texts/rawtext/vntidx.cpp | 185 +++++
src/modules/texts/swtext.cpp | 40 ++
src/modules/texts/ztext/Makefile | 5 +
src/modules/texts/ztext/Makefile.am | 4 +
src/modules/texts/ztext/gbfidx.cpp | 661 +++++++++++++++++
src/modules/texts/ztext/makeidx.c | 146 ++++
src/modules/texts/ztext/nasb.cpp | 107 +++
src/modules/texts/ztext/rawtxt2z.cpp | 457 ++++++++++++
src/modules/texts/ztext/ztext.cpp | 309 ++++++++
30 files changed, 7313 insertions(+)
create mode 100644 src/modules/texts/Makefile
create mode 100644 src/modules/texts/Makefile.am
create mode 100644 src/modules/texts/rawgbf/Gbf.c
create mode 100644 src/modules/texts/rawgbf/Gbf.pas
create mode 100644 src/modules/texts/rawgbf/Gbfmain.pas
create mode 100644 src/modules/texts/rawgbf/Makefile
create mode 100644 src/modules/texts/rawgbf/Makefile.am
create mode 100644 src/modules/texts/rawgbf/gbf.cpp
create mode 100644 src/modules/texts/rawgbf/gbf.h
create mode 100644 src/modules/texts/rawgbf/gbfidx.cpp
create mode 100644 src/modules/texts/rawgbf/rawgbf.cpp
create mode 100644 src/modules/texts/rawtext/Makefile
create mode 100644 src/modules/texts/rawtext/Makefile.am
create mode 100644 src/modules/texts/rawtext/kjvidx.cpp
create mode 100644 src/modules/texts/rawtext/makebnds.c
create mode 100644 src/modules/texts/rawtext/nuidx.cpp
create mode 100644 src/modules/texts/rawtext/ojbtxidx.c
create mode 100644 src/modules/texts/rawtext/rawtext.cpp
create mode 100644 src/modules/texts/rawtext/rawtxidx.c
create mode 100644 src/modules/texts/rawtext/rtfidx.cpp
create mode 100644 src/modules/texts/rawtext/svetxidx.c
create mode 100644 src/modules/texts/rawtext/vntidx.cpp
create mode 100644 src/modules/texts/swtext.cpp
create mode 100644 src/modules/texts/ztext/Makefile
create mode 100644 src/modules/texts/ztext/Makefile.am
create mode 100644 src/modules/texts/ztext/gbfidx.cpp
create mode 100644 src/modules/texts/ztext/makeidx.c
create mode 100644 src/modules/texts/ztext/nasb.cpp
create mode 100644 src/modules/texts/ztext/rawtxt2z.cpp
create mode 100644 src/modules/texts/ztext/ztext.cpp
(limited to 'src/modules/texts')
diff --git a/src/modules/texts/Makefile b/src/modules/texts/Makefile
new file mode 100644
index 0000000..1a2d00d
--- /dev/null
+++ b/src/modules/texts/Makefile
@@ -0,0 +1,5 @@
+
+root := ../../..
+
+all:
+ make -C ${root}
diff --git a/src/modules/texts/Makefile.am b/src/modules/texts/Makefile.am
new file mode 100644
index 0000000..b48d93e
--- /dev/null
+++ b/src/modules/texts/Makefile.am
@@ -0,0 +1,7 @@
+textsdir = $(top_srcdir)/src/modules/texts
+
+libsword_la_SOURCES += $(textsdir)/swtext.cpp
+
+include ../src/modules/texts/rawtext/Makefile.am
+include ../src/modules/texts/ztext/Makefile.am
+include ../src/modules/texts/rawgbf/Makefile.am
diff --git a/src/modules/texts/rawgbf/Gbf.c b/src/modules/texts/rawgbf/Gbf.c
new file mode 100644
index 0000000..2b7f786
--- /dev/null
+++ b/src/modules/texts/rawgbf/Gbf.c
@@ -0,0 +1,485 @@
+/* Output from p2c, the Pascal-to-C translator */
+/* From input file "Gbf.pas" */
+
+
+#include
+
+
+typedef enum {
+ tokNull, tokEOF, tokHeader, tokContent, tokTail, tokStyle, tokWord,
+ tokSpace, tokSync, tokControl, tokChar, tokFont
+} TToken;
+typedef enum {
+ caBold, caSmallCaps, caItalic, caOTQuote, caRed, caSuperscript, caUnderline,
+ caSubscript
+} TCharacterAttribute;
+typedef long TCharAttribs;
+
+
+
+typedef struct TBookNameRec {
+ Char Name[256], Abbr[256];
+ uchar Num;
+} TBookNameRec;
+
+typedef TBookNameRec TBookAbbr[116];
+
+
+typedef struct TReadGBF {
+ /* private*/
+ FILE *F;
+ Char FName[256], TokenLine[256];
+ long TokenPos;
+ boolean fFileIsOpen, fParagraphEnd, fInTitle, fInPsalmBookTitle,
+ fInHebrewTitle, fInSectionTitle;
+
+ /* public*/
+ Char sBook[256], sChapter[256], sVerse[256], sMode[256];
+ Char sContext[256]; /*// Last text type (header, body, or tail)*/
+ Char sTitle[256]; /*// Title of this book of the Bible*/
+ Char sPsalmBookTitle[256]; /*// Title of this Psalm book*/
+ Char sHebrewTitle[256]; /*// Psalm Hebrew title*/
+ Char sSectionTitle[256]; /*// Section headings*/
+ Char sDate[256], sFontName[256];
+ long iTotalWords;
+ Char chJustification, chDirection;
+ boolean fIndent, fPoetry;
+ TCharAttribs CharAttribs;
+ uchar bBk, bChap, bVs, bWd;
+ /*
+ function Init({const*/
+ /*sFileName: string): boolean;
+ procedure Done;
+ function GetToken(var TokenKind: TToken): string;
+ */
+} TReadGBF;
+
+typedef struct TWriteGBF {
+ /* private*/
+ FILE *F;
+ Char FName[256], LineOut[256];
+ boolean fFileIsOpen;
+ uchar bBk, bChap, bVs, bWd;
+
+ /* public*/
+ /*
+ function Init({const*/
+ /*sFileName: string): boolean;
+ function Done: boolean;
+ procedure Out({const*/
+ /*s: string);
+*/
+} TWriteGBF;
+
+/*implementation */
+
+
+/*//0*/
+/*//1*/
+/*//2*/
+/*//3*/
+/*//4*/
+/*//5*/
+/*//6*/
+/*//7*/
+/*//8*/
+/*//9*/
+/*//10*/
+/*//11*/
+/*//12*/
+/*//13*/
+/*//14*/
+/*//15*/
+/*//16*/
+/*//17*/
+/*//18*/
+/*//19*/
+/*//20*/
+/*//21*/
+/*//22*/
+/*//0*/
+/*//1*/
+/*//2*/
+/*//3*/
+/*//4*/
+/*//5*/
+/*//6*/
+/*//7*/
+/*//8*/
+/*//9*/
+/*//10*/
+/*//11*/
+/*//12*/
+/*//13*/
+/*//14*/
+/*//15*/
+/*//16*/
+/*//17*/
+/*//18*/
+/*//19*/
+/*//20*/
+/*//21*/
+/*//22*/
+/*//23*/
+/*//24*/
+/*//26*/
+/*//27*/
+/*//28*/
+/*//29*/
+/*//30*/
+/*//31*/
+/*//32*/
+/*//33*/
+/*//34*/
+/*//35*/
+/*//36*/
+/*//37*/
+/*//38*/
+/*//39*/
+/*//40*/
+/*//41*/
+/*//42*/
+/*//43*/
+/*//44*/
+/*//45*/
+/*//46*/
+/*//47*/
+/*//48*/
+/*//49*/
+/*//50*/
+/*//51*/
+/*//52*/
+/*//53*/
+/*//54*/
+/*//55*/
+/*//56*/
+/*//57*/
+/*//58*/
+/*//59*/
+/*//60*/
+/*//61*/
+/*//62*/
+/*//63*/
+/*//64*/
+/*//65*/
+/*//66*/
+/*//67*/
+/*//68*/
+/*//69*/
+/*//70*/
+/*//71*/
+/*//72*/
+/*//73*/
+/*//74*/
+/*//75*/
+/*//76*/
+/*//77*/
+/*//78*/
+/*//79*/
+/*//80*/
+/*//81*/
+/*//82*/
+/*//83*/
+/*//84*/
+/*//85*/
+/*//86*/
+/*//87*/
+/*//88*/
+/*//89*/
+/*//90*/
+/*//91*/
+/*//92*/
+
+Static TBookAbbr BookAbbr = {
+ { "1 Chronicles", "1CH", 13 },
+ { "1 Corinthians", "1CO", 70 },
+ { "1 Esdras", "1E", 52 },
+ { "1 John", "1J", 86 },
+ { "1 Kings", "1K", 11 },
+ { "1 Maccabees", "1M", 50 },
+ { "1 Peter", "1P", 84 },
+ { "1 Samuel", "1S", 9 },
+ { "1 Thessalonians", "1TH", 76 },
+ { "1 Timothy", "1TI", 78 },
+ { "2 Chronicles", "2CH", 14 },
+ { "2 Corinthians", "2CO", 71 },
+ { "2 Esdras", "2E", 56 },
+ { "2 John", "2J", 87 },
+ { "2 Kings", "2K", 12 },
+ { "2 Maccabees", "2M", 51 },
+ { "2 Peter", "2P", 85 },
+ { "2 Samuel", "2S", 10 },
+ { "2 Thessalonians", "2TH", 77 },
+ { "2 Timothy", "2TI", 79 },
+ { "3 John", "3J", 88 },
+ { "3 Maccabees", "3M", 55 },
+ { "4 Maccabees", "4M", 57 },
+ { "1 Chronicles", "1 CH", 13 },
+ { "1 Corinthians", "1 CO", 70 },
+ { "1 Esdras", "1 E", 52 },
+ { "1 John", "1 J", 86 },
+ { "1 Kings", "1 K", 11 },
+ { "1 Maccabees", "1 M", 50 },
+ { "1 Peter", "1 P", 84 },
+ { "1 Samuel", "1 S", 9 },
+ { "1 Thessalonians", "1 TH", 76 },
+ { "1 Timothy", "1 TI", 78 },
+ { "2 Chronicles", "2 CH", 14 },
+ { "2 Corinthians", "2 CO", 71 },
+ { "2 Esdras", "2 E", 56 },
+ { "2 John", "2 J", 87 },
+ { "2 Kings", "2 K", 12 },
+ { "2 Maccabees", "2 M", 51 },
+ { "2 Peter", "2 P", 85 },
+ { "2 Samuel", "2 S", 10 },
+ { "2 Thessalonians", "2 TH", 77 },
+ { "2 Timothy", "2 TI", 79 },
+ { "3 John", "3 J", 88 },
+ { "3 Maccabees", "3 M", 55 },
+ { "4 Maccabees", "4 M", 57 },
+ { "Acts", "AC", 68 },
+ { "Amos", "AM", 30 },
+ { "Prayer of Asariah and the Song of the Three Jews", "AZ", 47 },
+ { "Baruch", "BA", 45 },
+ { "Bel and the Dragon", "BE", 49 },
+ { "Colossians", "CO", 75 },
+ { "Daniel", "DA", 27 },
+ { "Deuteronomy", "DE", 5 },
+ { "Deuteronomy", "DT", 5 },
+ { "Ecclesiasties", "EC", 21 },
+ { "Esther", "ES", 17 },
+ { "Exodus", "EX", 2 },
+ { "Ezekiel", "EZE", 26 },
+ { "Ezra", "EZR", 15 },
+ { "Galatians", "GA", 72 },
+ { "Genesis", "GE", 1 },
+ { "Genesis", "GN", 1 },
+ { "Ephesians", "EP", 73 },
+ { "Esther (Greek)", "GR", 42 },
+ { "Habakkuk", "HAB", 35 },
+ { "Haggai", "HAG", 37 },
+ { "Hebrews", "HE", 82 },
+ { "Hosea", "HO", 28 },
+ { "Isaiah", "IS", 23 },
+ { "James", "JA", 83 },
+ { "Jeremiah", "JE", 24 },
+ { "Job", "JOB", 18 },
+ { "Joel", "JOE", 29 },
+ { "John", "JOH", 67 },
+ { "Jonah", "JON", 32 },
+ { "Joshua", "JOS", 6 },
+ { "Jude", "JUDE", 89 },
+ { "Judges", "JUDG", 7 },
+ { "Judith", "JUDI", 41 },
+ { "Lamentations", "LA", 25 },
+ { "Letter of Jeremiah", "LET", 46 },
+ { "Leviticus", "LEV", 3 },
+ { "Luke", "LK", 66 },
+ { "Leviticus", "LV", 3 },
+ { "Luke", "LU", 66 },
+ { "Malachi", "MAL", 39 },
+ { "Prayer of Manasseh", "MAN", 53 },
+ { "Mark", "MAR", 65 },
+ { "Matthew", "MAT", 64 },
+ { "Micah", "MI", 33 },
+ { "Nahum", "NA", 34 },
+ { "Nehemiah", "NE", 16 },
+ { "Numbers", "NU", 4 },
+ { "Obadiah", "OB", 31 },
+ { "Psalm 151", "P1", 54 },
+ { "Philemon", "PHILE", 81 },
+ { "Philippians", "PHILI", 74 },
+ { "Philemon", "PHM", 81 },
+ { "Philippians", "PHP", 74 },
+ { "Proverbs", "PR", 20 },
+ { "Psalms", "PS", 19 },
+ { "Revelation", "RE", 90 },
+ { "Romans", "RM", 69 },
+ { "Romans", "RO", 69 },
+ { "Ruth", "RU", 8 },
+ { "Sirach", "SI", 44 },
+ { "Song of Solomon", "SOL", 22 },
+ { "Song of Solomon", "SON", 22 },
+ { "Song of Solomon", "SS", 22 },
+ { "Susanna", "SU", 48 },
+ { "Titus", "TI", 80 },
+ { "Tobit", "TO", 40 },
+ { "Wisdom", "WI", 43 },
+ { "Zechariah", "ZEC", 38 },
+ { "Zephaniah", "ZEP", 36 }
+};
+
+/*// 0 - 7*/
+/*// 8 - 14*/
+/*// 15-20*/
+/*// 21-26*/
+/*// 27-33*/
+/*// 34-39*/
+/*// 40-45*/
+/*// 46-52*/
+/*// 53-63*/
+/*// 64-70*/
+/*// 71-78*/
+/*// 79-84*/
+
+Static Char BookFileName[91][256] = {
+ "", "Genesis", "Exodus", "Lev", "Num", "Deut", "Joshua", "Judges", "Ruth",
+ "1Sam", "2Sam", "1Kings", "2Kings", "1Chron", "2Chron", "Ezra", "Nehemiah",
+ "Esther", "Job", "Psalms", "Proverbs", "Eccl", "Song", "Isaiah", "Jeremiah",
+ "Lament", "Ezekiel", "Daniel", "Hosea", "Joel", "Amos", "Obadiah", "Jonah",
+ "Micah", "Nahum", "Habakkuk", "Zeph", "Haggai", "Zech", "Malachi", "Tobit",
+ "Judith", "Esther", "Wisdom", "Sirach", "Baruch", "Let", "Azar", "Susanna",
+ "Bel", "1Mac", "2Mac", "1Esdras", "Man", "P1", "3Mac", "2Esdras", "4Mac",
+ "", "", "", "", "", "", "Matthew", "Mark", "Luke", "John", "Acts", "Romans",
+ "1Cor", "2Cor", "Gal", "Eph", "Philip", "Col", "1Thes", "2Thes", "1Tim",
+ "2Tim", "Titus", "Philemon", "Hebrews", "James", "1Peter", "2Peter",
+ "1John", "2John", "3John", "Jude", "Rev"
+/* p2c: Gbf.pas, line 200:
+ * Note: Line breaker spent 0.0 seconds, 5000 tries on line 336 [251] */
+}; /*// 85-90*/
+
+
+Static boolean isletter(ch)
+Char ch;
+{
+ /*const*/
+ boolean Result;
+
+ if (isupper(ch)) {
+ Result = true;
+ return Result;
+ }
+ if (islower(ch))
+ Result = true;
+ else
+ Result = false;
+ return Result;
+}
+
+
+Static boolean isinword(ch)
+Char ch;
+{
+ /*const*/
+ boolean Result;
+
+ switch (ch) {
+
+ case '-':
+ Result = true;
+ break;
+
+ default:
+ if (isupper(ch))
+ Result = true;
+ else if (islower(ch))
+ Result = true;
+ else
+ Result = false;
+ break;
+ }
+ return Result;
+}
+
+
+Static boolean IsUpper(ch)
+Char ch;
+{
+ /*const*/
+ boolean Result;
+
+ if (isupper(ch))
+ Result = true;
+ else
+ Result = false;
+ return Result;
+}
+
+
+Static boolean IsDigit(ch)
+Char ch;
+{
+ /*const*/
+ boolean Result;
+
+ if (isdigit(ch))
+ Result = true;
+ else
+ Result = false;
+ return Result;
+}
+
+
+Static boolean MatchAbbrev(sName, sAbbrev)
+Char *sName, *sAbbrev;
+{
+ /*const*/
+ long i;
+ boolean Result;
+
+ if (strlen(sName) < strlen(sAbbrev)) {
+ Result = false;
+/* p2c: Gbf.pas, line 245: Warning: Symbol 'RESULT' is not defined [221] */
+ } else
+ Result = true;
+ i = 1;
+ while (i <= strlen(sAbbrev) && Result) {
+ if (toupper(sName[i - 1]) != sAbbrev[i - 1])
+ Result = false;
+ i++;
+ }
+}
+
+
+Static uchar BookNameToNumber(sBookName)
+Char *sBookName;
+{
+ /*const*/
+ long Result;
+
+ Result = 0;
+/* p2c: Gbf.pas, line 259: Warning: Symbol 'RESULT' is not defined [221] */
+ TRY(try1);
+ if (IsDigit(sBookName[strlen(sBookName) - 1]) & IsDigit(sBookName[0])) {
+ Result = StrToInt(sBookName);
+/* p2c: Gbf.pas, line 262:
+ * Warning: Symbol 'STRTOINT' is not defined [221] */
+ }
+ except();
+/* p2c: Gbf.pas, line 264: Warning: Symbol 'EXCEPT' is not defined [221] */
+/* p2c: Gbf.pas, line 264:
+ * Warning: Expected RECOVER, found 'Result' [227] */
+ RECOVER(try1);
+ ;
+ ENDTRY(try1);
+}
+
+
+main(argc, argv)
+int argc;
+Char *argv[];
+{ /*// Yuk! Linear search.*/
+ Char STR1[256];
+ uchar Result;
+
+/* p2c: Gbf.pas, line 266: Warning: Expected BEGIN, found 'i' [227] */
+ PASCAL_MAIN(argc, argv);
+ if (MatchAbbrev(sBookName, BookAbbr[i].Abbr)) {
+/* p2c: Gbf.pas, line 269:
+ * Warning: Symbol 'SBOOKNAME' is not defined [221] */
+/* p2c: Gbf.pas, line 269: Warning: Mixing non-strings with strings [170] */
+/* p2c: Gbf.pas, line 269: Warning: Symbol 'I' is not defined [221] */
+ Result = BookAbbr[i].Num;
+/* p2c: Gbf.pas, line 271: Warning: Symbol 'I' is not defined [221] */
+/* p2c: Gbf.pas, line 271: Warning: Symbol 'RESULT' is not defined [221] */
+ }
+/* p2c: Gbf.pas, line 273: Warning: Symbol 'I' is not defined [221] */
+ i++;
+ exit(EXIT_SUCCESS);
+}
+/* p2c: Gbf.pas, line 275:
+ * Warning: Junk at end of input file ignored [277] */
+
+
+
+/* End. */
diff --git a/src/modules/texts/rawgbf/Gbf.pas b/src/modules/texts/rawgbf/Gbf.pas
new file mode 100644
index 0000000..13826e3
--- /dev/null
+++ b/src/modules/texts/rawgbf/Gbf.pas
@@ -0,0 +1,735 @@
+type
+ TToken = (tokNull, tokEOF, tokHeader, tokContent, tokTail, tokStyle,
+ tokWord, tokSpace, tokSync, tokControl, tokChar, tokFont);
+ TCharacterAttribute = (caBold, caSmallCaps, caItalic, caOTQuote, caRed,
+ caSuperscript, caUnderline, caSubscript);
+ TCharAttribs = set of TCharacterAttribute;
+
+
+ TBookNameRec = record
+ Name,
+ Abbr: string;
+ Num: byte
+ end;
+
+ TBookAbbr = array[0..115] of TBookNameRec;
+
+const
+ BookAbbr: TBookAbbr = (
+ (Name: '1 Chronicles'; Abbr: '1CH'; Num: 13), {//0}
+ (Name: '1 Corinthians'; Abbr: '1CO'; Num: 70), {//1}
+ (Name: '1 Esdras'; Abbr: '1E'; Num: 52), {//2}
+ (Name: '1 John'; Abbr: '1J'; Num: 86), {//3}
+ (Name: '1 Kings'; Abbr: '1K'; Num: 11), {//4}
+ (Name: '1 Maccabees'; Abbr: '1M'; Num: 50), {//5}
+ (Name: '1 Peter'; Abbr: '1P'; Num: 84), {//6}
+ (Name: '1 Samuel'; Abbr: '1S'; Num: 9), {//7}
+ (Name: '1 Thessalonians'; Abbr: '1TH'; Num: 76), {//8}
+ (Name: '1 Timothy'; Abbr: '1TI'; Num: 78), {//9}
+ (Name: '2 Chronicles'; Abbr: '2CH'; Num: 14), {//10}
+ (Name: '2 Corinthians'; Abbr: '2CO'; Num: 71), {//11}
+ (Name: '2 Esdras'; Abbr: '2E'; Num: 56), {//12}
+ (Name: '2 John'; Abbr: '2J'; Num: 87), {//13}
+ (Name: '2 Kings'; Abbr: '2K'; Num: 12), {//14}
+ (Name: '2 Maccabees'; Abbr: '2M'; Num: 51), {//15}
+ (Name: '2 Peter'; Abbr: '2P'; Num: 85), {//16}
+ (Name: '2 Samuel'; Abbr: '2S'; Num: 10), {//17}
+ (Name: '2 Thessalonians'; Abbr: '2TH'; Num: 77), {//18}
+ (Name: '2 Timothy'; Abbr: '2TI'; Num: 79), {//19}
+ (Name: '3 John'; Abbr: '3J'; Num: 88), {//20}
+ (Name: '3 Maccabees'; Abbr: '3M'; Num: 55), {//21}
+ (Name: '4 Maccabees'; Abbr: '4M'; Num: 57), {//22}
+ (Name: '1 Chronicles'; Abbr: '1 CH'; Num: 13), {//0}
+ (Name: '1 Corinthians'; Abbr: '1 CO'; Num: 70), {//1}
+ (Name: '1 Esdras'; Abbr: '1 E'; Num: 52), {//2}
+ (Name: '1 John'; Abbr: '1 J'; Num: 86), {//3}
+ (Name: '1 Kings'; Abbr: '1 K'; Num: 11), {//4}
+ (Name: '1 Maccabees'; Abbr: '1 M'; Num: 50), {//5}
+ (Name: '1 Peter'; Abbr: '1 P'; Num: 84), {//6}
+ (Name: '1 Samuel'; Abbr: '1 S'; Num: 9), {//7}
+ (Name: '1 Thessalonians'; Abbr: '1 TH'; Num: 76), {//8}
+ (Name: '1 Timothy'; Abbr: '1 TI'; Num: 78), {//9}
+ (Name: '2 Chronicles'; Abbr: '2 CH'; Num: 14), {//10}
+ (Name: '2 Corinthians'; Abbr: '2 CO'; Num: 71), {//11}
+ (Name: '2 Esdras'; Abbr: '2 E'; Num: 56), {//12}
+ (Name: '2 John'; Abbr: '2 J'; Num: 87), {//13}
+ (Name: '2 Kings'; Abbr: '2 K'; Num: 12), {//14}
+ (Name: '2 Maccabees'; Abbr: '2 M'; Num: 51), {//15}
+ (Name: '2 Peter'; Abbr: '2 P'; Num: 85), {//16}
+ (Name: '2 Samuel'; Abbr: '2 S'; Num: 10), {//17}
+ (Name: '2 Thessalonians'; Abbr: '2 TH'; Num: 77), {//18}
+ (Name: '2 Timothy'; Abbr: '2 TI'; Num: 79), {//19}
+ (Name: '3 John'; Abbr: '3 J'; Num: 88), {//20}
+ (Name: '3 Maccabees'; Abbr: '3 M'; Num: 55), {//21}
+ (Name: '4 Maccabees'; Abbr: '4 M'; Num: 57), {//22}
+ (Name: 'Acts'; Abbr: 'AC'; Num: 68), {//23}
+ (Name: 'Amos'; Abbr: 'AM'; Num: 30), {//24}
+ (Name: 'Prayer of Asariah and the Song of the Three Jews'; Abbr: 'AZ'; Num: 47),
+ (Name: 'Baruch'; Abbr: 'BA'; Num: 45), {//26}
+ (Name: 'Bel and the Dragon';Abbr: 'BE'; Num: 49), {//27}
+ (Name: 'Colossians'; Abbr: 'CO'; Num: 75), {//28}
+ (Name: 'Daniel'; Abbr: 'DA'; Num: 27), {//29}
+ (Name: 'Deuteronomy'; Abbr: 'DE'; Num: 5), {//30}
+ (Name: 'Deuteronomy'; Abbr: 'DT'; Num: 5), {//31}
+ (Name: 'Ecclesiasties'; Abbr: 'EC'; Num: 21), {//32}
+ (Name: 'Esther'; Abbr: 'ES'; Num: 17), {//33}
+ (Name: 'Exodus'; Abbr: 'EX'; Num: 2), {//34}
+ (Name: 'Ezekiel'; Abbr: 'EZE'; Num: 26), {//35}
+ (Name: 'Ezra'; Abbr: 'EZR'; Num: 15), {//36}
+ (Name: 'Galatians'; Abbr: 'GA'; Num: 72), {//37}
+ (Name: 'Genesis'; Abbr: 'GE'; Num: 1), {//38}
+ (Name: 'Genesis'; Abbr: 'GN'; Num: 1), {//39}
+ (Name: 'Ephesians'; Abbr: 'EP'; Num: 73), {//40}
+ (Name: 'Esther (Greek)'; Abbr: 'GR'; Num: 42), {//41}
+ (Name: 'Habakkuk'; Abbr: 'HAB'; Num: 35), {//42}
+ (Name: 'Haggai'; Abbr: 'HAG'; Num: 37), {//43}
+ (Name: 'Hebrews'; Abbr: 'HE'; Num: 82), {//44}
+ (Name: 'Hosea'; Abbr: 'HO'; Num: 28), {//45}
+ (Name: 'Isaiah'; Abbr: 'IS'; Num: 23), {//46}
+ (Name: 'James'; Abbr: 'JA'; Num: 83), {//47}
+ (Name: 'Jeremiah'; Abbr: 'JE'; Num: 24), {//48}
+ (Name: 'Job'; Abbr: 'JOB'; Num: 18), {//49}
+ (Name: 'Joel'; Abbr: 'JOE'; Num: 29), {//50}
+ (Name: 'John'; Abbr: 'JOH'; Num: 67), {//51}
+ (Name: 'Jonah'; Abbr: 'JON'; Num: 32), {//52}
+ (Name: 'Joshua'; Abbr: 'JOS'; Num: 6), {//53}
+ (Name: 'Jude'; Abbr: 'JUDE'; Num: 89), {//54}
+ (Name: 'Judges'; Abbr: 'JUDG'; Num: 7), {//55}
+ (Name: 'Judith'; Abbr: 'JUDI'; Num: 41), {//56}
+ (Name: 'Lamentations'; Abbr: 'LA'; Num: 25), {//57}
+ (Name: 'Letter of Jeremiah';Abbr:'LET'; Num: 46), {//58}
+ (Name: 'Leviticus'; Abbr: 'LEV'; Num: 3), {//59}
+ (Name: 'Luke'; Abbr: 'LK'; Num: 66), {//60}
+ (Name: 'Leviticus'; Abbr: 'LV'; Num: 3), {//61}
+ (Name: 'Luke'; Abbr: 'LU'; Num: 66), {//62}
+ (Name: 'Malachi'; Abbr: 'MAL'; Num: 39), {//63}
+ (Name: 'Prayer of Manasseh';Abbr:'MAN'; Num: 53), {//64}
+ (Name: 'Mark'; Abbr: 'MAR'; Num: 65), {//65}
+ (Name: 'Matthew'; Abbr: 'MAT'; Num: 64), {//66}
+ (Name: 'Micah'; Abbr: 'MI'; Num: 33), {//67}
+ (Name: 'Nahum'; Abbr: 'NA'; Num: 34), {//68}
+ (Name: 'Nehemiah'; Abbr: 'NE'; Num: 16), {//69}
+ (Name: 'Numbers'; Abbr: 'NU'; Num: 4), {//70}
+ (Name: 'Obadiah'; Abbr: 'OB'; Num: 31), {//71}
+ (Name: 'Psalm 151'; Abbr: 'P1'; Num: 54), {//72}
+ (Name: 'Philemon'; Abbr: 'PHILE'; Num: 81), {//73}
+ (Name: 'Philippians'; Abbr: 'PHILI'; Num: 74), {//74}
+ (Name: 'Philemon'; Abbr: 'PHM'; Num: 81), {//75}
+ (Name: 'Philippians'; Abbr: 'PHP'; Num: 74), {//76}
+ (Name: 'Proverbs'; Abbr: 'PR'; Num: 20), {//77}
+ (Name: 'Psalms'; Abbr: 'PS'; Num: 19), {//78}
+ (Name: 'Revelation'; Abbr: 'RE'; Num: 90), {//79}
+ (Name: 'Romans'; Abbr: 'RM'; Num: 69), {//80}
+ (Name: 'Romans'; Abbr: 'RO'; Num: 69), {//81}
+ (Name: 'Ruth'; Abbr: 'RU'; Num: 8), {//82}
+ (Name: 'Sirach'; Abbr: 'SI'; Num: 44), {//83}
+ (Name: 'Song of Solomon'; Abbr: 'SOL'; Num: 22), {//84}
+ (Name: 'Song of Solomon'; Abbr: 'SON'; Num: 22), {//85}
+ (Name: 'Song of Solomon'; Abbr: 'SS'; Num: 22), {//86}
+ (Name: 'Susanna'; Abbr: 'SU'; Num: 48), {//87}
+ (Name: 'Titus'; Abbr: 'TI'; Num: 80), {//88}
+ (Name: 'Tobit'; Abbr: 'TO'; Num: 40), {//89}
+ (Name: 'Wisdom'; Abbr: 'WI'; Num: 43), {//90}
+ (Name: 'Zechariah'; Abbr: 'ZEC'; Num: 38), {//91}
+ (Name: 'Zephaniah'; Abbr: 'ZEP'; Num: 36) {//92}
+ );
+
+ BookFileName: array[0..90] of string = (
+ '','Genesis','Exodus','Lev','Num','Deut','Joshua','Judges', {// 0 - 7}
+ 'Ruth','1Sam','2Sam','1Kings','2Kings','1Chron','2Chron', {// 8 - 14}
+ 'Ezra','Nehemiah','Esther','Job','Psalms','Proverbs', {// 15-20}
+ 'Eccl','Song','Isaiah','Jeremiah','Lament','Ezekiel', {// 21-26}
+ 'Daniel','Hosea','Joel','Amos','Obadiah','Jonah','Micah', {// 27-33}
+ 'Nahum','Habakkuk','Zeph','Haggai','Zech','Malachi', {// 34-39}
+ 'Tobit','Judith','Esther','Wisdom','Sirach','Baruch', {// 40-45}
+ 'Let','Azar','Susanna','Bel','1Mac','2Mac','1Esdras', {// 46-52}
+ 'Man','P1','3Mac','2Esdras','4Mac','','','','','','', {// 53-63}
+ 'Matthew','Mark','Luke','John','Acts','Romans','1Cor', {// 64-70}
+ '2Cor','Gal','Eph','Philip','Col','1Thes','2Thes','1Tim', {// 71-78}
+ '2Tim','Titus','Philemon','Hebrews','James','1Peter', {// 79-84}
+ '2Peter','1John','2John','3John','Jude','Rev'); {// 85-90}
+
+type
+ TReadGBF = record
+{ private}
+ F: File;
+ FName, TokenLine: string;
+ TokenPos: integer;
+ fFileIsOpen, fParagraphEnd, fInTitle, fInPsalmBookTitle, fInHebrewTitle,
+ fInSectionTitle: boolean;
+
+{ public}
+ sBook, sChapter, sVerse, sMode: string;
+ sContext, {// Last text type (header, body, or tail)}
+ sTitle, {// Title of this book of the Bible}
+ sPsalmBookTitle, {// Title of this Psalm book}
+ sHebrewTitle, {// Psalm Hebrew title}
+ sSectionTitle, {// Section headings}
+ sDate,
+ sFontName: string;
+ iTotalWords: integer;
+ chJustification,
+ chDirection: char;
+ fIndent, fPoetry: boolean;
+ CharAttribs: TCharAttribs;
+ bBk, bChap, bVs, bWd: byte;
+{
+ function Init({const}{sFileName: string): boolean;
+ procedure Done;
+ function GetToken(var TokenKind: TToken): string;
+}
+ end;
+
+ TWriteGBF = record
+{ private}
+ F: File;
+ FName, LineOut: string;
+ fFileIsOpen: boolean;
+ bBk, bChap, bVs, bWd: byte;
+
+{ public}
+{
+ function Init({const}{sFileName: string): boolean;
+ function Done: boolean;
+ procedure Out({const}{s: string);
+}
+ end;
+
+{implementation }
+
+function isletter({const}ch: char): boolean;
+begin
+ case ch of
+ 'A'..'Z': isletter := true;
+ 'a'..'z': isletter := true;
+ else
+ isletter := false;
+ end;
+end;
+
+function isinword({const}ch: char): boolean;
+begin
+ case ch of
+ '-': isinword := true;
+ 'A'..'Z': isinword := true;
+ 'a'..'z': isinword := true;
+ else
+ isinword := false;
+ end;
+end;
+
+function IsUpper({const}ch: char): Boolean;
+begin
+ case ch of
+ 'A'..'Z': IsUpper := true;
+ else
+ IsUpper := false;
+ end;
+end;
+
+function IsDigit({const}ch: char): Boolean;
+begin
+ case ch of
+ '0'..'9': IsDigit := true;
+ else
+ IsDigit := false;
+ end;
+end;
+
+
+function MatchAbbrev({const}sName, sAbbrev: string): boolean;
+var i: integer;
+begin
+ if Length(sName) < Length(sAbbrev) then
+ Result := false
+ else
+ Result := true;
+ i := 1;
+ while (i <= Length(sAbbrev)) and Result do
+ begin
+ if UpCase(sName[i]) <> sAbbrev[i] then
+ Result := false;
+ inc(i);
+ end;
+end;
+
+function BookNameToNumber({const}sBookName: string): byte;
+var i: integer;
+begin
+ Result := 0;
+ try
+ if IsDigit(sBookName[Length(sBookName)]) and IsDigit(sBookName[1]) then
+ Result := StrToInt(sBookName);
+ except
+ Result := 0;
+ end;
+ i := 0;
+ while (Result = 0) and (i <= 115) do {// Yuk! Linear search.}
+ begin
+ if MatchAbbrev(sBookName,BookAbbr[i].Abbr) then
+ begin
+ Result := BookAbbr[i].Num;
+ end;
+ inc(i);
+ end;
+end;
+
+function BookNumberToName({const}bBookNum: byte): string;
+begin
+ if bBookNum <= 115 then
+ Result := BookAbbr[bBookNum].Name
+ else
+ Result := '';
+end;
+
+function ConformCase({const}sPat, sSrc: string): string;
+var i: integer;
+begin
+ Result := sSrc;
+ if (Length(sPat) > 0) and (Length(sSrc) > 0) then
+ begin
+ Result := LowerCase(sSrc);
+ if IsUpper(sPat[1]) then
+ Result[1] := UpCase(Result[1]);
+ if (Length(sPat) > 1) and (Length(sSrc) > 1) then
+ begin
+ if IsUpper(sPat[2]) then
+ begin
+ for i := 2 to Length(Result) do
+ Result[i] := UpCase(Result[i]);
+ end;
+ end;
+ end;
+end;
+
+function TReadGBF.Init({const}sFileName: string): boolean;
+var s: string;
+ tok: TToken;
+begin
+ try
+ fParagraphEnd := false;
+ bBk := 0;
+ bChap := 0;
+ bVs := 0;
+ bWd := 0;
+ iTotalWords := 0;
+ FName := sFileName;
+ Assign(F, FName);
+ reset(F);
+ readln(F, TokenLine);
+ TokenPos := 1;
+ fFileIsOpen := true;
+ repeat
+ s := GetToken(tok)
+ until (tok = tokEOF) or ((tok = tokHeader) and (s[3] = '0'));
+ Init := true;
+ except
+ Init := false;
+ fFileIsOpen := false;
+ end
+end;
+
+procedure TReadGBF.Done;
+begin
+ if fFileIsOpen then
+ begin
+ closefile(F);
+ fFileIsOpen := false;
+ end;
+end;
+
+function TReadGBF.GetToken(var TokenKind: TToken): string;
+var m: integer;
+begin
+ Result := '';
+ TokenKind := tokNull;
+ if TokenPos = 0 then
+ begin
+ if (not fFileIsOpen) or EOF(F) then
+ TokenKind := tokEOF
+ else
+ begin
+ ReadLn(F,TokenLine);
+ TokenPos := 1;
+ end;
+ end;
+ if TokenKind <> tokEOF then
+ begin
+ m := Length(TokenLine);
+ if TokenPos > m then
+ begin
+ TokenKind := tokSpace;
+ if fParagraphEnd then
+ fParagraphEnd := false
+ else
+ Result := ' ';
+ TokenPos := 0;
+ end
+ else
+ begin
+ if (TokenLine[TokenPos] = '<') then
+ begin
+ fParagraphEnd := false;
+ repeat
+ Result := Result + TokenLine[TokenPos];
+ inc(TokenPos);
+ until (TokenLine[TokenPos] = '>') or (TokenPos > m);
+ Result := Result + '>';
+ inc(TokenPos);
+ case result[2] of
+ 'B': begin {// File body text type}
+ TokenKind := tokContent;
+ sContext := Result;
+ end;
+ 'C': begin {// Special characters}
+ TokenKind := tokControl;
+ if (Result[3] = 'M') or (Result[3] = 'L') then
+ fParagraphEnd := true;
+ end;
+ 'D': begin {// Direction}
+ TokenKind := tokControl;
+ chDirection := Result[3];
+ end;
+ 'H': begin
+ TokenKind := tokHeader;
+ sContext := Result;
+ end;
+ 'F': begin {// Font attributes}
+ TokenKind := tokFont;
+ case Result[3] of
+ 'B': CharAttribs := CharAttribs + [caBold];
+ 'C': CharAttribs := CharAttribs + [caSmallCaps];
+ 'I': CharAttribs := CharAttribs + [caItalic];
+ 'N': sFontName := copy(Result,4,Length(Result)-4);
+ 'O': CharAttribs := CharAttribs + [caOTQuote];
+ 'R': CharAttribs := CharAttribs + [caRed];
+ 'S': CharAttribs := CharAttribs + [caSuperscript];
+ 'U': CharAttribs := CharAttribs + [caUnderline];
+ 'V': CharAttribs := CharAttribs + [caSubscript];
+ 'b': CharAttribs := CharAttribs - [caBold];
+ 'c': CharAttribs := CharAttribs - [caSmallCaps];
+ 'i': CharAttribs := CharAttribs - [caItalic];
+ 'n': sFontName := '';
+ 'o': CharAttribs := CharAttribs - [caOTQuote];
+ 'r': CharAttribs := CharAttribs - [caRed];
+ 's': CharAttribs := CharAttribs - [caSuperscript];
+ 'u': CharAttribs := CharAttribs - [caUnderline];
+ 'v': CharAttribs := CharAttribs - [caSubscript];
+
+ end;
+ end;
+ 'J': begin {// Justification}
+ TokenKind := tokStyle;
+ chJustification := Result[3];
+ end;
+ 'P': begin {// Poetry/prose, indent}
+ TokenKind := tokControl;
+ case Result[3] of
+ 'I': fIndent := true;
+ 'P': fPoetry := true;
+ 'i': fIndent := false;
+ 'p': fPoetry := false;
+ end;
+ end;
+ 'R': begin {// References and footnotes}
+ TokenKind := tokControl;
+ end;
+ 'S': begin {// sync mark}
+ TokenKind := TokSync;
+ case Result[3] of
+ 'B': begin {// Book}
+ sBook := system.copy(Result, 4, length(Result)-4);
+ sPsalmBookTitle := '';
+ if sBook = '' then
+ begin
+ inc(bBk);
+ sBook := BookNumberToName(bBk);
+ end
+ else
+ bBk := BookNameToNumber(sBook);
+ sTitle := sBook;
+ end;
+ 'C': begin {//chapter}
+ sChapter := system.copy(Result, 4, length(Result)-4);
+ if sChapter = '' then
+ begin
+ inc(bChap);
+ sChapter := IntToStr(bChap);
+ end
+ else
+ begin
+ try
+ bChap := StrToInt(sChapter);
+ except
+ showmessage('Non-numeric chapter: '+sBook+' '+sChapter);
+ end;
+ end;
+ sHebrewTitle := '';
+ end;
+ 'V': begin {// Verse}
+ bWd := 0;
+ sVerse := system.copy(Result, 4, length(Result)-4);
+ if sVerse = '' then
+ begin
+ inc(bVs);
+ sVerse := IntToStr(bVs);
+ end
+ else
+ begin
+ try
+ bVs := StrToInt(sVerse);
+ except
+ showmessage('Non-numeric verse: '+sBook+' '+sChapter+':'+sVerse);
+ end;
+ end;
+ end;
+ 'D': begin {// Date}
+ sDate := system.copy(Result, 3, length(Result)-4);
+ end;
+ end;
+ end;
+ 'T': begin {// Titles}
+ TokenKind := TokContent;
+ case Result[3] of
+ 'B':
+ begin
+ sPsalmBookTitle := '';
+ fInPsalmBookTitle := true;
+ end;
+ 'b': fInPsalmBookTitle := true;
+ 'H':
+ begin
+ sHebrewTitle := '';
+ fInHebrewTitle := true;
+ end;
+ 'h': fInHebrewTitle := false;
+ 'S':
+ begin
+ sSectionTitle := '';
+ fInSectionTitle := true;
+ end;
+ 's': fInSectionTitle := false;
+ 'T':
+ begin
+ sTitle := '';
+ fInTitle := true;
+ end;
+ 't': fInTitle := false;
+ end;
+ end;
+ 'Z': begin {// File tail}
+ TokenKind := tokTail;
+ sContext := Result;
+ if Result[3] = 'Z' then
+ done;
+ end;
+ else
+ TokenKind := TokControl;
+
+ end;
+ end
+ else if isletter(TokenLine[TokenPos]) then
+ begin {Word}
+ fParagraphEnd := false;
+ TokenKind := tokWord;
+ repeat
+ Result := Result + TokenLine[TokenPos];
+ inc(TokenPos);
+ until (TokenPos > m) or (not isinword(TokenLine[TokenPos]));
+ inc(bWd);
+ inc(iTotalWords);
+ end
+ else if ((TokenLine[TokenPos] = ' ') or (TokenLine[TokenPos] = #9)) then
+ begin
+ fParagraphEnd := false;
+ TokenKind := tokSpace;
+ Result := Result + TokenLine[TokenPos];
+ inc(TokenPos);
+ end
+ else
+ begin
+ fParagraphEnd := false;
+ TokenKind := tokChar;
+ Result := Result + TokenLine[TokenPos];
+ inc(TokenPos);
+ end
+ end;
+ end;
+ if ((TokenKind = tokWord) or (TokenKind = tokSpace) or
+ (TokenKind = tokChar)) then
+ begin
+ if fInTitle then
+ sTitle := sTitle + Result
+ else if fInPsalmBookTitle then
+ sPsalmBookTitle := sPsalmBookTitle + Result
+ else if fInHebrewTitle then
+ sHebrewTitle := sHebrewTitle + Result
+ else if fInSectionTitle then
+ sSectionTitle := sSectionTitle + Result;
+ end;
+end;
+
+function TWriteGBF.Init({const}sFileName: string): boolean;
+begin
+ try
+ bBk := 0;
+ bChap := 0;
+ bVs := 0;
+ bWd := 0;
+ LineOut := '';
+ FName := sFileName;
+ Assign(F, FName);
+ filemode := 1;
+ rewrite(F);
+ fFileIsOpen := true;
+ Init := true;
+ except
+ Init := false;
+ fFileIsOpen := false;
+ end
+end;
+
+function TWriteGBF.Done: boolean;
+begin
+ try
+ if fFileIsOpen then
+ begin
+ if LineOut <> '' then
+ begin
+ WriteLn(F, LineOut);
+ LineOut := '';
+ end;
+ CloseFile(F);
+ end;
+ Done := true;
+ except
+ Done := false;
+ end;
+end;
+
+procedure TWriteGBF.Out({const}s: string);
+var sPrint, sSave, sBook, sChapter, sVerse: string;
+ i: integer;
+ b: byte;
+begin
+ if (Length(s) > 0) and IsLetter(s[1]) then
+ begin
+ inc(bWd);
+ LineOut := LineOut + s;
+ end
+ else if Length(s) > 3 then
+ begin
+ if (s[1] = '<') and (s[2] = 'S') then
+ begin
+ case s[3] of
+ 'B': begin {// Book}
+ sBook := system.copy(s, 4, length(s)-4);
+ if sBook = '' then
+ begin
+ inc(bBk);
+ LineOut := LineOut + s;
+ end
+ else
+ begin
+ b := bBk;
+ bBk := BookNameToNumber(sBook);
+ if b <> bBk then
+ LineOut := LineOut + s;
+ end;
+ end;
+ 'C': begin {//chapter}
+ sChapter := system.copy(s, 4, length(s)-4);
+ if sChapter = '' then
+ begin
+ inc(bChap);
+ LineOut := LineOut + s;
+ end
+ else
+ begin
+ try
+{// b := bChap;}
+ bChap := StrToInt(sChapter);
+{// if b <> bChap then}
+ LineOut := LineOut + s;
+ except
+ showmessage('Non-numeric chapter: '+sBook+' '+sChapter);
+ end;
+ end;
+ end;
+ 'V': begin {// Verse}
+ bWd := 0;
+ sVerse := system.copy(s, 4, length(s)-4);
+ if sVerse = '' then
+ begin
+ inc(bVs);
+ LineOut := LineOut + s;
+ end
+ else
+ begin
+ try
+{// b := bVs;}
+ bVs := StrToInt(sVerse);
+{// if b <> bVs then}
+ LineOut := LineOut + s;
+ except
+ showmessage('Non-numeric verse: '+sBook+' '+sChapter+':'+sVerse);
+ end;
+ end;
+ end;
+ else
+ LineOut := LineOut + s;
+ end
+ end
+ else
+ LineOut := LineOut + s; {// Not a sync mark}
+ end
+ else {// other token, space, or punctuation}
+ LineOut := LineOut + s; {// Length <= 3}
+ if ((s = '') or (s = '')) then
+ begin
+ if (Length(LineOut) > 78) then
+ begin
+ i := 78;
+ while (i > 0) and (LineOut[i] <> ' ') do
+ dec(i);
+ if i < 1 then
+ begin
+ WriteLn(F,LineOut);
+ LineOut := '';
+ end
+ else
+ begin
+ sPrint := system.copy(LineOut,1,i-1);
+ sSave := system.copy(LineOut,i+1,Length(LineOut)-i);
+ WriteLn(F,sPrint);
+ WriteLn(F, sSave);
+ LineOut := '';
+ end
+ end
+ else
+ begin
+ WriteLn(F, LineOut);
+ LineOut := '';
+ end
+ end
+ else if (Length(LineOut) > 78) then
+ begin
+ i := 78;
+ while (i > 0) and (LineOut[i] <> ' ') do
+ dec(i);
+ if i < 1 then
+ begin
+ WriteLn(F,LineOut);
+ LineOut := '';
+ end
+ else
+ begin
+ sPrint := system.copy(LineOut,1,i-1);
+ sSave := system.copy(LineOut,i+1,Length(LineOut)-i);
+ WriteLn(F,sPrint);
+ LineOut := sSave;
+ end
+ end
+end;
+
+end.
diff --git a/src/modules/texts/rawgbf/Gbfmain.pas b/src/modules/texts/rawgbf/Gbfmain.pas
new file mode 100644
index 0000000..4377622
--- /dev/null
+++ b/src/modules/texts/rawgbf/Gbfmain.pas
@@ -0,0 +1,1267 @@
+unit GBFMain;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
+ Buttons, StdCtrls, ExtCtrls, GBF;
+
+const
+ sTitlePar = '\pard\plain \s1\fi432\sb240\sa60\keepn\widctlpar \b\f5\fs28\kerning28 ';
+ sNormalPar = '\pard\plain \fi432\widctlpar \f4 ';
+ sNormalQuotePar = '\pard\plain \s20\fi432\li432\widctlpar \f4 ';
+ sPoetryPar = '\pard\plain \s18\fi-432\li432\widctlpar \f4 ';
+ sPoetryQuotePar = '\pard\plain \s21\fi-432\li864\widctlpar \f4 ';
+ sHebrewTitlePar = '\pard\plain \s16\fi432\keep\keepn\widctlpar \f4\fs20 ';
+ sSelahPar = '\pard\plain \s19\qr\widctlpar \f4 ';
+ ANSI2OEM: array[0..255] of char =
+ ( #0, #1, #2, #3, #4, #5, #6, #7,
+ #8, #9, #10, #11, #12, #13, #14, #15,
+ #16, #17, #18, #19, #20, #21, #22, #23,
+ #24, #25, #26, #27, #28, #29, #30, #31,
+ #32, #33, #34, #35, #36, #37, #38, #39,
+ #40, #41, #42, #43, #44, #45, #46, #47,
+ #48, #49, #50, #51, #52, #53, #54, #55,
+ #56, #57, #58, #59, #60, #61, #62, #63,
+ #64, #65, #66, #67, #68, #69, #70, #71,
+ #72, #73, #74, #75, #76, #77, #78, #79,
+ #80, #81, #82, #83, #84, #85, #86, #87,
+ #88, #89, #90, #91, #92, #93, #94, #95,
+ #96, #97, #98, #99,#100,#101,#102,#103,
+ #104,#105,#106,#107,#108,#109,#110,#111,
+ #112,#113,#114,#115,#116,#117,#118,#119,
+ #120,#121,#122,#123,#124,#125,#126,#127,
+ #128,#129, ',', 'a', '"',#133,#197,#216,
+ '^', '%', 'S', '<',#140,#141,#142,#143,
+ #144, #96, #97, '"', '"',#249,#150,#151,
+ '~',#153, 's', '>',#156,#157,#158, 'Y',
+ ' ',#173,#155,#156,#232,#157,#124, #21,
+ #168,#169, 'a',#174,#170, '-',#174, '_',
+ #167,#241,#253, '3', #39,#230, #20,#254,
+ ',', '1', 'o',#175,#172,#171,#190,#168,
+ 'A', 'A', 'A', 'A',#142,#143,#198,#128,
+ 'E',#144, 'E',#142, 'I', 'I', 'I', 'I',
+ 'D',#165, 'O', 'O', 'O', 'O',#153, 'x',
+ '0', 'U', 'U', 'U',#154, 'Y', 'b',#225,
+ #133,#130,#131, 'a',#132,#134,#230,#135,
+ #138,#130,#136,#137,#141,#161,#140,#139,
+ #148,#164,#149,#162,#147, 'o',#148,#246,
+ 'o',#151,#163,#150,#129, 'y', 'b',#152);
+
+type
+ TGBFConverterMainForm = class(TForm)
+ SourceEdit: TEdit;
+ Label1: TLabel;
+ BrowseButton: TButton;
+ SaveDialog1: TSaveDialog;
+ OpenDialog1: TOpenDialog;
+ DestEdit: TEdit;
+ Label2: TLabel;
+ BrowseDestButton: TButton;
+ FormatRadioGroup: TRadioGroup;
+ GoBitBtn: TBitBtn;
+ CloseBitBtn: TBitBtn;
+ Timer1: TTimer;
+ VerseLabel: TLabel;
+ ApocryphaCheckBox: TCheckBox;
+ WdLabel: TLabel;
+ Label3: TLabel;
+ Label4: TLabel;
+ WEBDraftCheckBox: TCheckBox;
+ QuickButton: TButton;
+ procedure CloseBitBtnClick(Sender: TObject);
+ procedure GoBitBtnClick(Sender: TObject);
+ procedure Timer1Timer(Sender: TObject);
+ procedure FormShow(Sender: TObject);
+ procedure FormatRadioGroupClick(Sender: TObject);
+ procedure QuickConversion;
+ procedure DoConversion;
+ procedure QuickButtonClick(Sender: TObject);
+ procedure FormActivate(Sender: TObject);
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ end;
+
+var
+ GBFConverterMainForm: TGBFConverterMainForm;
+
+implementation
+
+{$R *.DFM}
+
+var InFile: TReadGBF;
+ OutGBF: TWriteGBF;
+ OutFile: TextFile;
+
+function ANSIToOEM(s: string): string;
+var i, j: integer;
+begin
+ Result := s;
+ j := 1;
+ for i := 1 to length(s) do
+ begin
+ case s[i] of
+ #133:
+ begin
+ Result[j] := '.';
+ inc(j);
+ Insert('..', Result, j);
+ inc(j);
+ end;
+ #140:
+ begin
+ Result[j] := 'O';
+ inc(j);
+ Insert('E', Result, j);
+ end;
+ #150:
+ begin
+ Result[j] := '-';
+ inc(j);
+ Insert('-', Result, j);
+ end;
+ #151:
+ begin
+ Result[j] := '-';
+ inc(j);
+ Insert('-', Result, j);
+ end;
+ #153:
+ begin
+ Result[j] := '(';
+ inc(j);
+ Insert('TM)', Result, j);
+ inc(j,2);
+ end;
+ #156:
+ begin
+ Result[j] := 'o';
+ inc(j);
+ Insert('e', Result, j);
+ end;
+ #169:
+ begin
+ Result[j] := '(';
+ inc(j);
+ Insert('C)',Result, j);
+ inc(j);
+ end;
+ #174:
+ begin
+ Result[j] := '(';
+ inc(j);
+ Insert('R)',Result, j);
+ inc(j);
+ end;
+ #198:
+ begin
+ Result[j] := 'A';
+ inc(j);
+ Insert('E', Result, j);
+ end;
+ #230:
+ begin
+ Result[j] := 'a';
+ inc(j);
+ Insert('e', Result, j);
+ end;
+ else
+ Result[j] := ANSI2OEM[ord(s[i])];
+ end;
+ inc(j);
+ end;
+end;
+
+procedure TGBFConverterMainForm.CloseBitBtnClick(Sender: TObject);
+begin
+ Close;
+end;
+
+procedure TGBFConverterMainForm.DoConversion;
+var LastBook, wd, ParagraphAttributes, s, sLine, sPrint, sSave,
+ OutFileName: string;
+ LinePos, i, iFileNumber: integer;
+ tok: TToken;
+ fInclude, fProse, fSkip, fHTMLisOpen, fRed, fASCIIisOpen: boolean;
+ bLastBook, bChap: byte;
+
+ procedure CheckEOL;
+ begin
+ if Length(sLine) > 65 then
+ begin
+ i := 65;
+ while (i > 0) and (sLine[i] <> ' ') do
+ dec(i);
+ if i < 1 then
+ begin
+ if fASCIIisOpen then WriteLn(OutFile,sLine);
+ if fProse then
+ sLine := ''
+ else
+ sLine := ' ';
+ end
+ else
+ begin
+ sPrint := system.copy(sLine,1,i-1);
+ if fProse then
+ sSave := system.copy(sLine,i+1,Length(sLine)-i)
+ else
+ sSave := ' '+system.copy(sLine,i+1,Length(sLine)-i);
+ if fASCIIisOpen then WriteLn(OutFile,sPrint);
+ sLine := sSave;
+ end
+ end;
+ end;
+
+ procedure StartNewLine;
+ begin
+ if fInclude then
+ begin
+ CheckEol;
+ if fASCIIisOpen then WriteLn(OutFile, sLine);
+ sLine := '';
+ end;
+ end;
+
+ procedure CloseHTML;
+ begin
+ if fHTMLisOpen then
+ begin
+ WriteLn(OutFile,sLine);
+ sLine := '';
+ WriteLn(OutFile,'
');
+ WriteLn(OutFile,'
[Index] ');
+ WriteLn(OutFile,'[Home]');
+ WriteLn(OutFile,'