summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Little <chrislit@crosswire.org>2009-03-10 11:36:04 +0000
committerChris Little <chrislit@crosswire.org>2009-03-10 11:36:04 +0000
commit1fb974ac6a1a6b11be022e1530940aa78972e424 (patch)
tree57f1e0eb746383e17743e9a59da88f4021d8d339
parent13c772acd3613d44424bd54a6374555c6c51de18 (diff)
downloadsword-tools-1fb974ac6a1a6b11be022e1530940aa78972e424.tar.gz
finished more of the conversion script (constructs the [on]tbooks[] arrays)
git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@159 07627401-56e2-0310-80f4-f8cd0041bdcd
-rw-r--r--versification/v11nsys.pl47
1 files changed, 36 insertions, 11 deletions
diff --git a/versification/v11nsys.pl b/versification/v11nsys.pl
index cff2bc6..239aa35 100644
--- a/versification/v11nsys.pl
+++ b/versification/v11nsys.pl
@@ -13,6 +13,18 @@ sub cleanupLine {
return $ret;
}
+sub buildBooks {
+ if ($lastBook eq "Matt") {
+ $otnt = 1;
+ }
+ if ($otnt == 0) {
+ $otbooks .= "\t{\"$idmap{$lastBook}\", \"$lastBook\", \"$lastBook\", $lastChap},\n";
+ }
+ else {
+ $ntbooks .= "\t{\"$idmap{$lastBook}\", \"$lastBook\", \"$lastBook\", $lastChap},\n";
+ }
+}
+
# @canons will contain this list of files, these are in a basic XML format.
# Each file lists osisIDs along with the English names associated with the
# osisID. These aren't exhaustive, and may or may not overlap (but hopefully
@@ -69,42 +81,55 @@ foreach $infile (@srcfiles) {
$thisBook = "";
$thisChap = "";
$thisVers = "";
-
+
$vm = "/******************************************************************************\n * Maximum verses per chapter\n */\n\nint vm$v11n\[\] = {";
-
+ $otbooks = "/******************************************************************************\n * [on]tbooks$v11n - initialize static instance for all canonical text names\n * and chapmax\n */\nstruct sbook otbooks$v11n\[\] = {\n";
+ $ntbooks = "struct sbook ntbooks$v11n\[\] = {\n";
+ $booksCloser = "\t{\"\", \"\", \"\", 0}\n};\n";
+
+ $otnt = 0; # 0 = ot, 1 = nt
+
while (<INF>) {
$line = $_;
-
+
$line = cleanupLine($line);
-
+
if ($line =~ /<osisID.+?code=\"(.+?)\"\/>/) {
$osisID = $1;
$lastBook = $thisBook;
$lastChap = $thisChap;
$lastVers = $thisVers;
-
+
$osisID =~ /([^\.]+)\.(\d+)\.(\d+)/;
-
+
$thisBook = $1;
$thisChap = $2;
$thisVers = $3;
-
+
if ((($thisBook ne $lastBook) ||($thisChap ne $lastChap)) && $lastVers ne "") {
$vm .= "$lastVers, ";
}
if ($thisBook ne $lastBook) {
$vm .= "\n\t// $idmap{$thisBook}\n\t";
+ if ($lastBook ne "") {
+ buildBooks{};
+ }
}
}
}
$vm .= "$thisVers\n};\n";
-
- print OUTF "$vm";
-
+ buildBooks();
+ $otbooks .= $booksCloser;
+ $ntbooks .= $booksCloser;
+
+ print OUTF $otbooks;
+ print OUTF $ntbooks;
+ print OUTF $vm;
+
print OUTF "\nSWORD_NAMESPACE_END\n\n#endif\n";
-
+
close (INF);
close (OUTF);
}